Map<String, String> map = new HashMap<String, String>();
for(int i=0;i<10000;i++){
map.put("key"+i, "value"+i);
}
long begin = System.currentTimeMillis();
// for(String key : map.keySet()){
// System.out.println("key= "+key+"_____value= "+map.get(key));
// }//Balance = 468
// Iterator<Map.Entry<String, String>> it = map.entrySet().iterator();
// while (it.hasNext()) {
// Map.Entry<String,String> entry2 = (Map.Entry<String,String>) it
// .next();
// System.out.println("key= "+entry2.getKey()+"_____value= "+entry2.getValue());
// }//Balance = 406
for(Map.Entry<String, String> entry :map.entrySet()){
System.out.println("key= "+entry.getKey()+"_____value= "+entry.getValue());
}//Balance = 344
long end = System.currentTimeMillis();
System.out.println("Balance = "+ (end-begin));
这里都是第一次run得到的result