test.java
747 Bytes
package com.huaheng.test;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class test {
public static void main(String[] args) {
List<String> strList = new ArrayList<String>();
strList.add("test_01");
strList.add("test_02");
strList.add("test_03");
Iterator<String> it = strList.iterator();
System.out.println("Iterator 删除前 数据"+strList.toString());
while (it.hasNext()) {
String next = it.next();
System.out.println(strList.toString());
if(next.equals("test_02")){
it.remove();
}
}
System.out.println("Iterator 删除后 数据"+strList.toString());
}
}