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
Can we use return in constructor?
what is server side caching?
What is a function in programming?
Why string is called as immutable?
What is the difference between a break statement and a continue statement?
Explain what is Marker interface?
What is the point of polymorphism java?
How does remove work in java?
Is set ordered?
what is difference betweem home interface and remote interface?
What are voids?
What is a boolean output?
What are constants?
How do you convert bytes to character in java?
How are the elements of a gridbaglayout organized in java programming?