Search code examples
javalistdictionarycollections

How do I convert a Map to List in Java?


How do I convert a Map<key,value> to a List<value>? Should I iterate over all map values and insert them into a list?


Solution

  • List<Value> list = new ArrayList<Value>(map.values());
    

    assuming:

    Map<Key,Value> map;