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


Please Help Members By Posting Answers For Below Questions

What is a line break example?

577


What are the types of sockets in java?

540


What is a Presistent Object?

638


what is synchronization and why is it important? : Java thread

584


How are the elements of a gridbaglayout organized?

543






What is integer parseint?

549


What is cr keyboard?

652


Where are variables stored?

551


What is the difference between yielding and sleeping?

554


What does arrays sort do in java?

536


What are different access specifiers in java? Explain

628


Why are variables important in research?

550


What is the synonym of string?

533


What is difference between class and object in java?

524


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

1659