移除list里面的值
public class IteratorTest { public static void main(String[] args) { List<String> list = new ArrayList<String>(); list.add("aaa"); list.add("bbb"); list.add("ccc"); Iterator<String> iterator = list.iterator(); while (iterator.hasNext()) { String test = iterator.next(); if ("aaa".equals(test)) { iterator.remove(); } } for (String s: list) { System.out.print(s); } } }