java集合容器

collection    map两大类集合

collection中有list 、queue、set.接口。

实现以上接口的类主要有ArrayList、linkList、hashSet、hashMap、LinkedhashSet、LinkedhashMap、TreeSet、treeMap


迭代器的使用:

List <string>list=new ArrayList<string>();

list.add(xxx)

list.add(xxx)

Iterator<string> it=list.iterator();

while(it.hasNext())

{

system.out.println(it.next())

}

map迭代器的推荐用法:

Map<string,string>map=new HashMap<string,string>();

map.put(xxx,xxx)

map.put(xxx,xxx)

while(map.Entry<string,string>entry : map.entrySet()){

    system.out.println(entry.getKey(),entry.getValue())

}



©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。