//第一种方式
Set<String> keySet = map.keySet();
Iterator it = keySet.iterator();
while(it.hasNext()){
String key = (String)it.next();
String value = map.get(key);
System.out.println(key+"------"+value);
}
//第二种方式
Set<Entry<String,String>> set = map.entrySet();
Iterator it1 = set.iterator();
while(it1.hasNext()){
Entry<String,String> entry = (Entry<String,String>)it1.next();
String key = entry.getKey();
String value = entry.getValue();
System.out.println(key+"------"+value);
}
//第三种方式
for(Entry<String,String> entry : map.entrySet()){
System.out.println((String)entry.getKey() + "------"
+ (String)entry.getValue());
} |
|