【发布时间】:2010-11-13 13:18:21
【问题描述】:
我有一个 ListIterator<PointF> 列表作为类字段。我填写方法grow()。当我尝试使用此列表中的迭代器时,我得到ConcurrentModificationException。
ListIterator<ListIterator<PointF>> i = mPoints.listIterator();
while (i.hasNext()) {
ListIterator<PointF> j = i.next();
if (j.hasNext())
PointF tmp = j.next(); // Exception here
}
我不知道为什么这段代码会在任何方法中导致异常除了 grow()
【问题讨论】:
-
请发布一个简短但完整的程序来演示该问题。
-
@Jon Skeet 问题解决了,我在获取迭代器后修改了我的列表
mPoints。
标签: java collections iterator