HashMap<Integer, Integer> table = new HashMap<>(); for(Map.Entry<Integer, Integer> key: table.entrySet()){ System.out.println(key.getKey() + " " + key.getValue()); }