How to get values and keys from HashMap?

前端 未结 10 1582
無奈伤痛
無奈伤痛 2020-12-08 01:56

I\'m writing a simple edit text in Java. When the user opens it, a file will be opened in JTabbedPane. I did the following to save the files opened:

10条回答
  •  无人及你
    2020-12-08 02:35

    You have to follow the following sequence of opeartions:

    • Convert Map to MapSet with map.entrySet();
    • Get the iterator with Mapset.iterator();
    • Get Map.Entry with iterator.next();
    • use Entry.getKey() and Entry.getValue()
    # define Map
    for (Map.Entry entry: map.entrySet)
        System.out.println(entry.getKey() + entry.getValue);
    

提交回复
热议问题