How do I dump the contents of a hash map?

后端 未结 3 835
难免孤独
难免孤独 2021-01-17 11:02

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

3条回答
  •  Happy的楠姐
    2021-01-17 11:40

    Use HashMap.toString() (docs here):

    System.out.println("HASH MAP DUMP: " + myHashMap.toString());
    

    Generally, use Object.toString() to dump data like this.

提交回复
热议问题