Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

first none duplicated char

import java.util.Scanner;

public class FirstDuplicate
{
    private static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args)
    {
        System.out.println("Enter random chars");
        String s = new String(scanner.nextLine());
        findTheFirstDublicate(s);

    }
    private static boolean findTheFirstDublicate(String s)
    {
        int[] arr = new int[26];

        for(int i=0 ; i<s.length() ; ++i)
        {
          int c =  s.charAt(i)-'a';
          ++arr[c];
        }
        pint(arr);
        return false;
    }

    private static void pint(int[] arr){
        int i = 0 ;
        while(i < arr.length){
            if(arr[i] == 1){
                System.out.println("First none duplicated letters "+((char)(i+'a')));
            }
            ++i;
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: session management in java spring boot for login logut 
Java :: actionlistener 
Java :: Java Create a WeakHashMap 
Java :: print all prime no java 
Java :: how to create a sublist in java 
Java :: Java extends and implements clause 
Java :: .code domain 
Java :: What is builder tool 
Java :: java.lang.NullPointerException: Cannot store to double array because is null 
Java :: java get wrapper class for primitive 
Java :: close current file android studio shortct 
Java :: android how to get month on world programmatically 
Java :: null check in line java 
Java :: grava 
Java :: assigning value with for each 
Java :: i have use tried catch but still prints exception java 
Java :: how to use asynx task to make api connection java 
Java :: read only jtextfield 
Java :: pagina en java 
Java :: how to call values from methods in flutter 
Java :: The root directory of the External Storage on every android version 
Java :: Create four (4) Java classes named Color, Model, Car, and CarDemo. 
Java :: matrix program 
Java :: android studio press button programmatically 
Java :: implement hashmap 
Java :: create a file in java in user home 
Java :: instance block 
Java :: how to split each string of a line 
Java :: time in java 
Java :: Java Catching base and child exception classes 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =