I am wondering any utility to print out map quickly for debugging purpose.
You can just print the toString()
of a Map
to get a 1-line version of the map, divided up in to key/value entries. If that isn't readable enough, you could do your own looping to print or use Guava to do this:
System.out.println(Joiner.on('\n').withKeyValueSeparator(" -> ").join(map));
That'll give you output of the form
key1 -> value1 key2 -> value2 ...
I guess, the .toString() method of implementing class (HashMap or TreeMap for ex.) will do what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With