Collectors provide utility functions to transform stream results into various collection types.
Source Code
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class CollectorsExample {
public static void main(String[] args) {
List list = Stream.of("a", "b", "c", "d")
.collect(Collectors.toList());
System.out.println(list);
}
}