package aaa;
import java.util.ArrayList;
import java.util.ListIterator;
public class String_a {
public static void sop(Object obj)
{
System.out.println(obj);
}
public static void main(String[] args) {
ArrayList a1=new ArrayList();
a1.add("java01");
a1.add("java02");
ListIterator ls=a1.listIterator();
while(ls.hasNext())
{
Object obj=ls.next();;
if(obj.equals("java02"))
{
a1.add("jaadd");
}
}
sop(a1);
}
}
控制台错误
Exception in thread "main" java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(Unknown Source)
at java.util.AbstractList$Itr.next(Unknown Source)
at aaa.String_a.main(String_a.java:23)
// 不明白??? |
|