how to identify duplicate values in arraylist
Answers were Sorted based on User's Feedback
Answer / shrinu nallavelli
arrayList elements are differentiated by their index values
onlu..
| Is This Answer Correct ? | 3 Yes | 3 No |
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 |
In java, what is the difference between method overloading and method overriding?
What are the different types of data structures in java?
What happens if an exception is not handled in a program?
What lambda means?
can any one send me the example program of immutable class?
Can we have two main methods in a java class?
How to convert a string to long?
What is the difference between parameters and arguments ?
What does percent mean in java?
What are possible key words, we can use to declare a class?
Give me some null interfaces in java?
What is nullpointerexception?