この小さなコードは、奇妙にも、上記のExceptionをスローします。 はまた、ウェブを中心に掲載のコードを見て、これは正しいと思わ:なぜIterator.next()がConcurrentModificationExceptionをスローするのですか
import java.util.ArrayList;
import java.util.Iterator;
public class IteratorTest {
ArrayList<Integer> arr = new ArrayList<Integer>();
Iterator i = arr.iterator();
public void show() {
arr.add(2);
arr.add(5);
arr.add(9);
while(i.hasNext()){
System.out.println(i.next());
}
}
}
任意のアドバイスはありますか? おかげ
http://stackoverflow.com/questions/223918/iterating-through-a-collection-avoiding-concurrentmodificationexception-when-re – Raedwald