package chapter6;

import java.util.ArrayList;
import java.util.Iterator;

public class Example04 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("张三");
        list.add("李四");
        list.add("王五");
        list.add("张三");

        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            String name = iterator.next();
            if (name.equals("张三")) {
                iterator.remove();
            }
        }

        System.out.println(list);
    }
}
