/*
* 错误
*/
public static void remove31(List list, String target){
Iterator iter = list.iterator();
while (iter.hasNext()) {
String item = iter.next();
if (item.equals(target)) {
list.remove(item);
}
}
print(list);
}
/*
* 正确
*/
public static void remove32(List list, String target){
Iterator iter = list.iterator();
while (iter.hasNext()) {
String item = iter.next();
if (item.equals(target)) {
iter.remove();
}
}
print(list);
}