나는 다음과 같은 코드를하지만 난 keySet()
와지도 키를 반복하면서지도에서 값을 가져 오는 심지어 내가 경고를 얻을 findBugs와 실수는 것을보고이 WMI_WRONG_MAP_ITERATOR
방지 map.get (키) 방법
for(String elementId : mapElements.keySet()){
element = mapElements.get(elementId);
doSomething(element);
}
그럼 왜 이것이 좋지 않은가, 어떻게 해결할 수 있을까?
감사합니다.
for (Map.Entry<String, String> entry : mapElements.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
// Use the key and the value
}
을 또는 당신이 정말로 그렇게하지 않으면 그냥 값을 반복, 키가 필요합니다 :
물론 이것은 설명서 (http://findbugs.sourceforge.net/bugDescriptions.html#WMI_WRONG_MAP_ITERATOR)에서 설명합니다. –