I solves this, but with other code because this dont work.
But, why this code dont work? i think the problem is that entrada.next().getValue(); and entrada2.next().getValue(); in the first time compare the same key.
public static void removeFirstNameDuplicates(Map<String, String> map) {
ArrayList<String> removes = new ArrayList<String>(10);
Iterator <HashMap.Entry<String,String>> entrada = map.entrySet().iterator();
Iterator <HashMap.Entry<String,String>> entrada2 = map.entrySet().iterator();
while(entrada.hasNext()) {
String b = entrada.next().getValue();
while(entrada2.hasNext()){
String c = entrada2.next().getValue();
System.out.println("c" + "" + c );
if(b.equals(c)){
removes.add(b);
}
}
}
System.out.println(removes);
for(String s : removes){
removeItemFromMapByValue(map, s);
}
Why my code dont work
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Andrey
26 January 2020, 21:20
You should read this https://codegym.cc/groups/posts/20-deleting-an-element-from-an-arraylist
+2
LucGar
26 January 2020, 22:00
thanks
0