How can I dump the contents of a Java HashMap(or any other), for example to STDOUT ?
As an example, suppose that I have a complex HashMap of the following structure :
( student1 => Map( name => Tim,
Scores => Map( math => 10,
physics => 20,
Computers => 30),
place => Miami,
ranking => Array(2,8,1,13),
),
student2 => Map (
...............
...............
),
............................
............................
);
So I would like to print it to the screen in order to get an idea about the data structure.
I am looking for something similar to PHP’s var_dump() or Perl’s dumper().
Use
HashMap.toString()(docs here):Generally, use
Object.toString()to dump data like this.