Java - Simple way to put LinkedHashMap keys/values into respective Lists?

后端 未结 3 1397
-上瘾入骨i
-上瘾入骨i 2021-02-18 23:33

I have a LinkedHashMap < String, String > map .

List < String > keyList;
List < String > valueList;

map.keySet();
map.values();
<         


        
3条回答
  •  我寻月下人不归
    2021-02-18 23:51

    Most collections accept Collection as a constructor argument:

    List keyList = new ArrayList(map.keySet());
    List valueList = new ArrayList(map.values());
    

提交回复
热议问题