I have the following code but i saw that retrieving values from a Map while iterating over the Map keys with keySet()
is a mistake even with findBugs i get the warning WMI_WRONG_MAP_ITERATOR
for(String elementId : mapElements.keySet()){
element = mapElements.get(elementId);
doSomething(element);
}
so why exactly is this not good and how can i fix it ?
Thanks.