package chapter6;


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


public class Example23 {
    public static void main(String[] args) {
        // 存放字符串的集合
        ArrayList<String> names = new ArrayList<String>();
        names.add("张三");  // √ 正确

        Iterator it1 = names.iterator();
        while (it1.hasNext()) {
            String name = (String) it1.next();
            System.out.println(name);
        }

        ArrayList students = new ArrayList();
        names.add("张三");

        Iterator it2 = students.iterator();
        while (it2.hasNext()) {
            String student = (String) it2.next();
            System.out.println(student);
        }
    }
}
