Java - Simple way to put LinkedHashMap keys/values into respective Lists?
Most collections accept Collection
as a constructor argument:
List<String> keyList = new ArrayList<String>(map.keySet());
List<String> valueList = new ArrayList<String>(map.values());
For sure!
keyList.addAll(map.keySet());
Or you could pass it at the time of creation as well
List<String> keyList = new ArrayList<String>(map.KeySet());
http://download.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html