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 |
How do you sort arrays in java?
What is difference between jdk,jre and jvm?
what is difference between requestprocessor and request dispatcher?
how we can make a write-only class in java?
What is serialversionuid?
What is the mapping mechanism used by java to identify IDL language?
What is the difference between a method and a procedure?
What is data movement?
Explain where variables are created in memory?
How to add menushortcut to menu item?
"we cannot create an object of interface but we can create a variable of it".diacuss the statement with the help of an example.
Why java applets are more useful for intranets as compared to internet?