I think System.out.println works fine with the map, since this:
Map<String, Integer> map = new HashMap<String, Integer>(); map.put("key1", 1); map.put("key2", 2); System.out.println(map);
prints:
{key1=1, key2=2}
Or you can define the utility method as follows:
public void printMap(Map<?, ?> map) { for (Entry<?, ?> e : map.entrySet()) { System.out.println("Key: " + e.getKey() + ", Value: " + e.getValue()); } }
source share