@Test public void test() { Mapmap = new HashMap (); map.put("key1", "value1"); map.put("key2", "value2"); // 1 for (Map.Entry ent : map.entrySet()) { System.out.println(ent.getKey() + "-" + ent.getValue()); } // 2 Iterator > ite = map.entrySet().iterator(); while(ite.hasNext()) { Entry ent = ite.next(); System.out.println(ent.getKey() + " -- " + ent.getValue()); } // 3 for(String key : map.keySet()){ System.out.println(key + " --- " + map.get(key)); } }