java_集合Collection

集合的每个内部类里面都有一个独有的迭代器,ArrayList\LinkedList\HashSet 里面都继承了Collection的迭代器

Collection c=new ArrayList()  //继承
Iterator it=c.iterator()   //返回当前集合的迭代器对象
while(it.hasNext()){   //遍历  只有集合里有元素才去拿
    System.out.print(it.next());
    }
        Collection a=new ArrayList();
        a.add("江小白");
        a.add(true);
        //a.remove(1);
        a.addAll(b);
        System.out.println(((ArrayList) a).contains(true));
//        for(int i=0;i<a.size();i++){
//            System.out.println(((ArrayList) a).get(i));
//        }        

 Map

 

posted @ 2020-07-29 12:01  xinZhiZhu  阅读(93)  评论(0编辑  收藏  举报