How to get values and keys from HashMap?

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

    To get values and keys you could just use the methods values() and keySet() of HashMap

    public static List getValues(Map map) {
        return new ArrayList(map.values());
    }
    
    public static List getKeys(Map map) {
        return new ArrayList(map.keySet());
    }
    

提交回复
热议问题