Guys although I've solved the task I don't understand why the following solution doesn't work. I know I can't use a ' for loop ' to remove elements but this seems to make sense ,but it doesn't work. Iv'e tried googling with no satisfactory answers. Why doesn't this work : Iterator <Map.Entry<String,String>>iterator = map.entrySet().iterator(); while (iterator.hasNext()){ Map.Entry<String,String> pair = iterator.next(); String name = pair.getValue(); removeItemFromMapByValue(map,name); }