How to count occurrences of each duplicate element in a list
{a,b,d,c,a,b} ?
Thanks in Advance
Answer Posted / lal ajith kumara
Since java.Util.Set is not allowing duplicates u can use it
String[] letters = {"a", "b", "b", "c" ,"a", "d","a"};
Set duplicateTester = new HashSet<String>();
for(int i = 0; i<letters.length;i++){
if(true == duplicateTester.add(letters[i])){
System.out.println("true>>"+letters[i]);
}else{
System.out.println("false>>"+letters[i]);
}
}
| Is This Answer Correct ? | 7 Yes | 1 No |
Post New Answer View All Answers
What is arguments in java?
What is meant by class and object in java?
define polymorphism in java
What is the function of java?
What is mean by encoding?
What is the difference between a synchronized method and a synchronized block?
I want my class to be developed in such a way that no other class (even derived class) can create its objects. Define how can I do so?
What are inbuilt functions in java?
What is the method overriding?
What is thread count in java?
What is complexity in java?
Give few difference between constructor and method?
Is 64bit faster than 32 bit?
Is binary a low level language?
How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters in java programming?