0
Hashmap Question
Why is F and G not Printed? https://code.sololearn.com/ca104A4a38A3
2 Respuestas
+ 3
Because you iterate from 1 to the map's length, which is 5 after the removal so the loop breaks before you get to F and G which have a higher value.
You probably want to do something along the lines of:
for( String value : map.values() )
{
System.out.println( value );
}
+ 2
Sanoj
I have explained well in this code. You should not use loop like that to get values.
https://code.sololearn.com/cOyT6rJ43t7T/?ref=app
You can iterate Map like this:
for (Map.Entry<Integer, String> m : map.entrySet()) {
System.out.print(m.getValue() + " ");
}