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 the difference between Grid and Gridbaglayout?
What is the final blank variable?
What is the difference between abstract classes and interfaces?
What is the use of runnable interface?
Is 0 an even number?
What is parsing a string?
Explain about object oriented programming and its features?
What are the types of casting?
What are advantages of exception handling in java?
What is the use of using enum to declare a constant?
What is the use of default method in interface in java?
What is module in oop?
What are some alternatives to inheritance?
Why wait and notify methods are declared in object class?
What about instanceof operator in java?