1. ConcurrentModificationException 在遍历容器的同时修改容器里的成员对象可能会抛出该异常
http://www.blogjava.net/EvanLiu/archive/2008/08/31/224453.html
故在迭代的同时删除容器里的元素要用迭代器的iter.remove()方法,而不要使用容器自带的remove(obj)方法。例如:
Iterator<Element> e = list.iterator(); while(e.hasNext()){ Element element = e.next(); if(condition){ e.remove(); } }
foreach(element e: list){ if(condition){ list.remove(e); //throw ConcurrentModificationException } };
2.
原文:http://www.cnblogs.com/xingyun/p/4358289.html