public static void testErgodicMethod(HashMap<String,String> map){
for (Map.Entry<String, String> entry : map.entrySet()){
String key = entry.getKey();
String value = entry.getValue();
System.out.println("key: "+key+" value: "+value);
}
}
public static void testErgodicMethod1(HashMap<String,String> map){
//结合迭代器
Iterator it = map.entrySet().iterator();
while (it.hasNext()){
Map.Entry<String,String> entry = (Map.Entry<String, String>) it.next();
String key = entry.getKey();
String value = entry.getValue();
System.out.println("key: "+key+" value: "+value);
}
}