Map遍历操作

>>>>>>>>>>>>>>正确方法:
Iterator<Entry<String, ArrayList<String>>> blockIterator = blockMap.entrySet().iterator(); while(blockIterator.hasNext()){ Entry<String, ArrayList<String>> entry= blockIterator.next(); String key_date = entry.getKey(); if(key_date.compareTo(sformat.format(date))<=0){ blockIterator.remove(); } }

>>>>>>>>>>>这个方法是错误的!!!!!!!!
for(String key_date : blockMap.keySet()){ if(key_date.compareTo(sformat.format(date))<=0){ blockMap.remove(key_date);,//不能再迭代的时候删除!!!; } }
原文地址:https://www.cnblogs.com/mr-level/p/5283192.html