Java Language Create a list from an existing Set


Example

Using a new List

List<String> list = new ArrayList<String>(listOfElements);

Using List.addAll() method

    Set<String> set = new HashSet<String>();
    set.add("foo");
    set.add("boo");
    
    List<String> list = new ArrayList<String>();
    list.addAll(set);

Using Java 8 Steam API

List<String> list = set.stream().collect(Collectors.toList());