public class dublicate { public static void isDuplicate(Character arr) { int len=0; while(arr!=null) len++; Set<character> set=new HashSet<character>(Arrays.asList(arr)); int len2=set.size(); if(len==len2) System.out.println("array doesn't have duplicates"); else System.out.println("yes they have duplicates\n"); } public static void main(String args[]) { Scanner s=new Scanner(System.in); System.out.println("enter elements in an array to check it contains duplicate elements or not\n"); Character arr[]=new Character[100]; for(Character c:arr) arr[c]=s.next().charAt(0); } }
for(Character c:arr) arr[c]=s.next().charAt(0);
split(" ");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)