- 一、java中遍历hashmap:
for (Map.Entry<String, Integer> entry : tempMap.entrySet()) {
String key = entry.getKey().toString();
String value = entry.getValue().toString();
System.out.println("key=" + key + " value=" + value);
}
System.out.println("");
- 二、java中遍历hashset:
Iterator it=set.iterator();
while(it.hasNext())
String s=it.next().toString();
- 三、遍历Vector
//遍历Vector中的元素
for(int i = 0;i < v.size();i++){
System.out.println(v.get(i));
}
for(int i = 0;i < v.size();i++){
System.out.println(v.get(i));
}
四、遍历 arraylist
for(int i = 0;i < list.size(); i ++){
System.out.println(list.get(i));
}
System.out.println(list.get(i));
}