June 2017
Beginner
1296 pages
69h 23m
English
... arrays or from ranges of elements in the arrays.
Stream and Collecting the ResultsThe stream pipeline in lines 16–18
Arrays.stream(values)
.sorted()
.collect(Collectors.toList())
uses stream techniques to sort the values array and collect the results in a List<Integer>. First, line 16 creates a Stream<Integer> from values. Next, line 17 calls Stream method sorted to sort the elements—this results in an intermediate Stream<Integer> with the values in ascending order. (Section 17.11.3 discusses how to sort in descending order.)
When processing streams, you often create new collections containing the results so that you can perform operations on them later. To do so, ...
Read now
Unlock full access