Printing HashMap In Java

后端 未结 15 1724
半阙折子戏
半阙折子戏 2020-11-28 19:32

I have a HashMap:

private HashMap example = new HashMap();

Now I would lik

15条回答
  •  生来不讨喜
    2020-11-28 19:49

    Assuming you have a Map, you can print it like this:

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

提交回复
热议问题