How to convert Java Stream to List
Convert Java Stream to List
Following code show how to convert the stream intStream to list using collect.
// Converting Streams to Collection
Stream<Integer> intStream = Stream.of(1, 2, 3, 4, 5);
List<Integer> list = intStream.collect(Collectors.toList());
System.out.println(list); // prints [1, 2, 3, 4, 5]
No comments :
Post a Comment
Please leave your message queries or suggetions.