public void operate(List list){
for (Iterator it = list.iterator(); it.hasNext();) {
String str = (String)it.next();
if (str.equals("-")){
list.remove(str);
}
}
}因为list在循环中的时候是不可以删除它的元素的
这样写就没有问题
for (Iterator it = list.iterator(); it.hasNext();) {
String str = (String)it.next();
if (str.equals("-")){
it.remove();
}
}
原文网址:http://harveyzeng.iteye.com/blog/1667091