Iteration迭代器

使用iteration迭代器的关键代码

        //使用多态方法
        Collection<String> coll = new ArrayList<String>();
        //调用父类collection中的iteration方法
        Iterator<String> it = coll.iterator();
        //调用iteration接口的hasNext方法和next方法
        while(it.hasNext()) {
            String s = it.next();
            System.out.println();

 

posted @ 2018-06-25 21:47  BatmanY  阅读(135)  评论(0)    收藏  举报