//方法一 Set<String> set = map.keySet(); for (String s:set) { System.out.println(s+","+map.get(s)); }
//方法二:将Map集合中的映射关系(Map.Entry类型的)取出,存入到Set集合中 for Iterator it = tempMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Object key = entry.getKey(); Object value = entry.getValue(); System.out.println("key=" + key + " value=" + value); } // 方法三
for (Map.Entry entry : tempMap.entrySet()) { String key = entry.getKey().toString(); String value = entry.getValue().toString(); System.out.println("key=" + key + " value=" + value); }