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 square a number?
What are desktop procedures?
What is an empirical question?
What is the use of arraylist class in java?
Can we use String with switch case?
What is difference between path and classpath?
What is the difference between superclass and subclass?
What advantage do java's layout managers provide over traditional windowing systems?
Why do we use bufferedreader?
Explain about assignment statement?
What is an object in java?
What are basic keywords?
Why constructor has no return type?
What is a parameter example?
What is the difference between conversation & casting?