// Declare and Initialize the Collection
Set<Integer> intSet = new HashSet<Integer>();
// Add Elements
intSet.add(1);
intSet.add(2);
intSet.add(3);
intSet.add(4);
// Use the stream and collectors to get List out of Set
List li = intSet.stream().collect(Collectors.toList());
System.out.println(li); // Prints [1, 2, 3, 4]
|