import java.util.HashMap; public class Test { public static void main(String[] args) { HashMap map = new HashMap<>(); map.put("Tobias", 22); map.put("Per", 42); map.put("Kevin", 12); map.put("Kevin", 52); for (String key : map.keySet()) { System.out.println(key + " " + map.get(key)); } for (HashMap.Entry e : map.entrySet()) { System.out.println(e.getKey()); System.out.println(e.getValue()); } } }