爱笑火

文章
4
资源
0
加入时间
4年2月16天

java.util.ConcurrentModificationException详解

【引言】经常在迭代集合元素时,会想对集合做修改(add/remove)操作,类似下面这段代码:for (Iterator it = list.iterator(); it.hasNext(); ) { Integer val = it.next(); if (val == 5) { list.remove(val); }}运行这段代码,会抛出异