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

In java, what is the difference between method overloading and method overriding?

0 Answers  


What are the different types of data structures in java?

0 Answers  


What happens if an exception is not handled in a program?

0 Answers  


What lambda means?

0 Answers  


can any one send me the example program of immutable class?

2 Answers   Arfin, TCS,


Can we have two main methods in a java class?

0 Answers  


How to convert a string to long?

2 Answers  


What is the difference between parameters and arguments ?

2 Answers  


What does percent mean in java?

0 Answers  


What are possible key words, we can use to declare a class?

2 Answers   Tech Mahindra,


Give me some null interfaces in java?

0 Answers  


What is nullpointerexception?

0 Answers  


Categories