【发布时间】:2013-12-20 11:04:16
【问题描述】:
我收到了CurrentModificationException,但我不知道为什么。这是我的代码:
Iterator<Ficha> itFichas = puzzle.iterator();
Iterator<Integer> index = randomNum.iterator();
while(itFichas.hasNext() && index.hasNext()){
PAleatorio.add(index.next(),itFichas.next());
}
我之前将puzzle 定义为ArrayList<Integer>。和randomNum,PAleatorio 作为ArrayList<Ficha>。
为什么会出现异常?
编辑:
ArrayList<Ficha> PAleatorio = finalList;
其中 finalList 是另一个包含多个 Ficha 的列表:
ArrayList<Ficha> finalList = new ArrayList<Ficha>();
finalList.add(new Ficha("1"));
finalList.add(new Ficha("2"));
finalList.add(new Ficha("3"));
finalList.add(new Ficha("4"));
【问题讨论】:
-
你能出示PAleatorio的声明
-
只是发布更多的上下文和异常的堆栈跟踪。
-
很可能,
puzzle和PAleatorio指的是同一个对象。 -
@GopalRao 我已将其添加到帖子中。
-
现在请显示拼图的声明。