To print a map in Java, call the
System.out.println
method.For example, this will print {Hello=1, World=2}
:
Map<String, Integer> map = new LinkedHashMap<>();
map.put("Hello", 1);
map.put("World", 2);
System.out.println(map); // {Hello=1, World=2}