Class StreamCollectToListExample

java.lang.Object
modernfeatures.streams.StreamCollectToListExample

public class StreamCollectToListExample extends Object
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 Details

    • StreamCollectToListExample

      public StreamCollectToListExample()
  • Method Details

    • main

      public static void main(String[] args)
      Main method demonstrating the use of Stream pipeline operations.
      1. Filter names longer than 3 characters
      2. Convert names to uppercase
      3. Sort names alphabetically
      4. Collect the results into a List
      5. Print each name in the final List
      Parameters:
      args - Command-line arguments (not used)