1 //1, get both key and value 2 for(Entry<Integer, String> entry : map.entrySet()) 3 { 4 Integer key = entry.getKey(); 5 String value = entry.getValue(); 6 } 7 8 //2, get key or value 9 for(Integer key : map.keySet()) 10 { 11 Integer k = key; 12 } 13 14 for(String value : map.values()) 15 { 16 String v = value; 17 } 18 19 20 //3, use Iterator, !!! recommend: iterator.remove() 21 Iterator<Entry<Integer, String>> itr = map.entrySet().iterator(); 22 while(itr.hasNext()) 23 { 24 Map.Entry<Integer, String> entry = itr.next(); 25 Integer key = entry.getKey(); 26 String value = entry.getValue(); 27 }