Convert Collection to List

collections, java

Solution

If you have already created an instance of your List subtype (e.g., ArrayList, LinkedList), you could use the addAll method.

e.g.,

l.addAll(myCollection)

Many list subtypes can also take the source collection in their constructor.

Problem

I would like to ask: how do you convert a `Collection` to a `List` in Java?

Original source

Related problems