ArrayList al = new ArrayList();
al.add(“a”);
al.add(“b”);
al.add(“c”);
Iterator it = al.iterator();
while(it.hasNext()){
String s = (String)it.next();
if(s.equals(“c”)){
al.add(“c1”);
}
}
System.out.println(al);
a)[a,b,c]
b)[c1]
c)[a,b,c,c1]
d)抛出ConcurrentModificationException异常 |
|