运行时报错
Exception in thread "main" java.util.ConcurrentModificationException
原因:在遍历集合时,对集合结构进行了修改
如
List<Integer> list = new ArrayList<>();
list.add(1);
for(Integer value : list) {
list.remove(0);
}
解决:避免在遍历集合时修改其结构
Java源码层面的原因请参考:https://blog.csdn.net/u012926924/article/details/50452411