米字键

博客园 首页 新随笔 联系 订阅 管理

public class GH {

    public static void main(String[] args) {

  //使用多态的方式来创建集合
            Collection co=new ArrayList<String>();

    //分别赋五个值
            co.add("张");
            co.add("张1");
            co.add("张2");
            co.add("张3");
            co.add("张4");

 

  //使用迭代的方式来遍历添加的内容
            Iterator it=co.iterator();

    //用while判断一下
            while (it.hasNext()){


                String s=(String)it.next();


                System.out.println(s);
            }
            
}

}

posted on 2019-03-21 11:57  米字键  阅读(109)  评论(0编辑  收藏  举报