Map<String,String> map = new HashMap<String,String>():
map.put("1","熬力名");
map.put("2","朱志明");
map.put("3","张世坤");
第一种
for (String key : map.keySet()) {
log.info("key_"+key +"_value="+map.get(key));
}
第二种
Iterator<Map.Entry<String, String>> it = map.entrySet().iterator();
while(it.hasNext()){
Map.Entry<String, String> entry = it.next();
log.info("key_"+entry.getKey()+"_value_"+entry.getValue());
}
第三种
推荐,尤其是容量大时
for (Map.Entry<String, String> entry: map.entrySet()) {
log.info("key_"+entry.getKey()+"_value_"+entry.getValue());
}
第四种
for (String v: map.values()) {
log.info("value_"+v);
}