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 a line break example?
What are the types of sockets in java?
What is a Presistent Object?
what is synchronization and why is it important? : Java thread
How are the elements of a gridbaglayout organized?
What is integer parseint?
What is cr keyboard?
Where are variables stored?
What is the difference between yielding and sleeping?
What does arrays sort do in java?
What are different access specifiers in java? Explain
Why are variables important in research?
What is the synonym of string?
What is difference between class and object in java?
whar are the draw backs of programming lang step by step in Clang and next in C++ and next and in Java nad in .Net