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
How do you do exponents in java?
What is the integer of 16?
What is the purpose of interface?
Difference between start() and run() method of thread class?
What is codebase?
What is the use of http-tunneling in rmi?
What is arraylist e in java?
What is keyword in oop?
What is the difference between instanceof and isinstance?
Can private class be inherited in java?
What is application tier?
How many bytes is double?
How do you include a string in java?
What is an interface in java? Explain
Can a static class have a constructor?