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 |
Is string is a data type?
What is a Null object?
Explain about the main() method in java?
What do you mean by garbage collection used in java?
Why method overriding is used?
What is the list interface in java programming?
What is inner class?what is the use of inner class?where we create the object for inner class? and inner class can extend any class or inner class can implement any interface?
Hi Anyone know the model / questions of the Federal bank sample questions for the post of Specialist Officers - Programmers. Please post if anyone have..
What is immutable in java?
Define Multiprogramming and Multiprocessing in java.
0 Answers Akamai Technologies,
Is it possible to use Semaphore/ Mutex in an Interrupt Handler?
Explain list interface?