Iterator it = list.iterator();while(it.hasNext()){
String x = it.next();
if(x.equals("del")){
it.remove();
}
}
使用iterator的remove方法,如果用list的remove方法同样会报上面提到的ConcurrentModificationException错误。
Iterator it = list.iterator();while(it.hasNext()){
String x = it.next();
if(x.equals("del")){
it.remove();
}
}
使用iterator的remove方法,如果用list的remove方法同样会报上面提到的ConcurrentModificationException错误。