1、删除list的正确方式
```swift
public class ArrayListRemove {
List list = new ArrayList<>();
list.add("北京");
list.add("上海");
list.add("广州");
list.add("深圳");
list.add("厦门");
list.add("南京");
removeList(list, "上海");
}
public static void removeList(List list, String target){
Iterator iter = list.iterator();
String item = "";
while(iter.hasNext()){
item = iter.next();
if(item.equals(target)){
iter.remove();
}
}
print(list);
}
private static void print(List list){
for(String item : list){
System.out.println("元素值:" + item);
}
}
}
```
代码```
list
```
网友评论