Package modernfeatures.streams
Class StreamCollectToListExample
java.lang.Object
modernfeatures.streams.StreamCollectToListExample
Demonstrates the use of Java 8 Streams to filter, transform, sort, and collect results into a List.
This example shows how to:
- Create a Stream from a List
- Filter elements using a Predicate
- Transform elements using a Function
- Sort the results
- Collect the results into a List
- Process the final List with a Consumer
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
StreamCollectToListExample
public StreamCollectToListExample()
-
-
Method Details
-
main
Main method demonstrating the use of Stream pipeline operations.- Filter names longer than 3 characters
- Convert names to uppercase
- Sort names alphabetically
- Collect the results into a List
- Print each name in the final List
- Parameters:
args
- Command-line arguments (not used)
-