如果这样写的话,就会出现异常
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();
}
}