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 |
What are the two types of java programming?
What will happen if static modifier is removed from the signature of the main method?
Is string is a data type in java?
Does chrome use java?
Define an applet in java?
What is the purpose of checked and unchecked exceptions in JAVA?
What is the difference between the direct buffer and non-direct buffer in java?
Can two objects have same hashcode?
What is main function purpose?
What is a parameter used for?
How to validate the request (Eg:user name and password) in session(http session)? not in LDAP server ?
Does treeset use compareto?