标签:java equals system ash static print obj pre util
public static void main(String[] args) throws Exception{
Map<String,Object> aa=new HashMap<String, Object>();
aa.put("a1","a1");
aa.put("a2","a2");
aa.put("a3","a3");
aa.put("a4","a4");
Set<String> ss=aa.keySet();
Iterator it=ss.iterator();
while(it.hasNext()){
Object key=it.next();
if("a1".equals(key)){
aa.put("aa1","aa1");
}
}
System.out.println(aa);
}
报错如下:
Exception in thread "main" java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1437)
at java.util.HashMap$KeyIterator.next(HashMap.java:1461)
标签:java equals system ash static print obj pre util
原文地址:https://www.cnblogs.com/duanxianyouyang/p/13172323.html