- toCollection operation on Collection provides a way to aggregate the result of a stream operation into a Collection.
int stream one two three-three
IntStream oneToThree_three = IntStream.of(1, 2, 3, 3);
USAGE
TreeSet resultCollection = oneToThree_three.boxed()
.filter(number -> number > 2)
.collect(Collectors.toCollection(TreeSet::new));
Comments
Post a comment