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 the difference between Grid and Gridbaglayout?

1251


What is the final blank variable?

1146


What is the difference between abstract classes and interfaces?

1028


What is the use of runnable interface?

1175


Is 0 an even number?

988


What is parsing a string?

1178


Explain about object oriented programming and its features?

1015


What are the types of casting?

1072


What are advantages of exception handling in java?

1026


What is the use of using enum to declare a constant?

1029


What is the use of default method in interface in java?

1011


What is module in oop?

1021


What are some alternatives to inheritance?

1113


Why wait and notify methods are declared in object class?

1045


What about instanceof operator in java?

1026