I don't understand why do I need to create a copy of the method argument, otherwise I get a weird Concurrent exception!
My code that didn't work is this:
public static void removeItemFromMap(HashMap<String, Integer> map) {
//write your code here
for (Map.Entry<String, Integer> entry: map.entrySet()) {
String key = entry.getKey();
Integer val = entry.getValue();
if (val < 500) {
map.remove(key);
}
}
}
But when I create a copy of the map argument and use that in my for loop, everything seems to work fine! What the Concurrent exception thing is all about??!!