17.4.5 Sorting Previously Collected Results

Lines 40–42 use the greaterThan4 collection that was created in lines 24–27 to show additional processing on a collection containing the results of a prior stream pipeline. In this case, we use streams to sort the values in greaterThan4, collect the results into a new List<Integers> and display the sorted values.

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.