Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 arguments in java?

965


What is meant by class and object in java?

981


define polymorphism in java

1051


What is the function of java?

955


What is mean by encoding?

1035


What is the difference between a synchronized method and a synchronized block?

1031


I want my class to be developed in such a way that no other class (even derived class) can create its objects. Define how can I do so?

1127


What are inbuilt functions in java?

1009


What is the method overriding?

1052


What is thread count in java?

962


What is complexity in java?

979


Give few difference between constructor and method?

922


Is 64bit faster than 32 bit?

1022


Is binary a low level language?

876


How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters in java programming?

962