class="lang-java prettyprint prettyprinted">monospace, sans-serif; white-space: inherit;">Iterator it = map.entrySet().iterator();while(it.hasNext()){Entry item = it.next();
map.remove(item.getKey());}
这种方法会出现错误
?
正确的删除办法是
Iterator it = map.entrySet().iterator();
? ?while (it.hasNext())
? ?{
? ? ? Entry item = it.next();
? ? ? it.remove();
? ?}
?
?
?