I am looking for a nice way to pretty-print a Map
.
map.toString()
gives me: {key1=value1, key2=value2, key3=value3}
I
You should be able to do what you want by doing:
System.out.println(map)
for example
As long as ALL your objects in the map have overiden the toString
method you would see:
{key1=value1, key2=value2}
in a meaningfull manner
If this is for your code, then overiding toString
is a good habit and I suggest you go for that instead.
For your example where your objects are String
s you should be fine without anything else.
I.e. System.out.println(map)
would print exactly what you need without any extra code