Multi-line pretty-printing of (nested) collections in Java

后端 未结 4 655
-上瘾入骨i
-上瘾入骨i 2020-12-17 22:39

I want to be able to (pretty-)print the contents of my maps.

They should have newlines and indentation rather than on a single line; ignoring the toString methods of

4条回答
  •  长情又很酷
    2020-12-17 23:01

    I am not 100% sure, might be is this what you are looking for and which you called pretty printing -

    Map map = new HashMap();
    ...
    for(Map.Entry entry: map.entrySet()){
        System.out.println(entry.getKey()+" - "+ entry.getValue());
    }
    

提交回复
热议问题