collection ?? map兩大類集合
collection中有l(wèi)ist 融痛、queue朝聋、set.接口沉馆。
實(shí)現(xiàn)以上接口的類主要有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())
}