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 identify duplicate values in arraylist

Answers were Sorted based on User's Feedback



how to identify duplicate values in arraylist..

Answer / shrinu nallavelli

arrayList elements are differentiated by their index values
onlu..

Is This Answer Correct ?    3 Yes 3 No

how to identify duplicate values in arraylist..

Answer / srikanth m

List<String> list = new ArrayList<String>();
list.add("abc");
list.add("def");
list.add("abc");




HashMap<String, Integer> map = new HashMap<String, Integer>();




for (String str : list) {
Integer c = (Integer) map.get(str);
if (c == null || c == 0) {
map.put(str, 1);
} else {
map.put(str, ++c);
}
}
System.out.println(map);

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What are the two types of java programming?

0 Answers  


What will happen if static modifier is removed from the signature of the main method?

0 Answers  


Is string is a data type in java?

0 Answers  


Does chrome use java?

0 Answers  


Define an applet in java?

0 Answers  


What is the purpose of checked and unchecked exceptions in JAVA?

0 Answers   Amdocs,


What is the difference between the direct buffer and non-direct buffer in java?

0 Answers  


Can two objects have same hashcode?

0 Answers  


What is main function purpose?

0 Answers  


What is a parameter used for?

0 Answers  


How to validate the request (Eg:user name and password) in session(http session)? not in LDAP server ?

1 Answers   Saksoft,


Does treeset use compareto?

0 Answers  


Categories