How to get values and keys from HashMap?

前端 未结 10 1586
無奈伤痛
無奈伤痛 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:42

    You could use iterator to do that:

    For keys:

    for (Iterator  itr= hash.keySet().iterator(); itr.hasNext();) {
        // use itr.next() to get the key value
    }
    

    You can use iterator similarly with values.

提交回复
热议问题