Class StreamBasicsPrintNamesAlpha

java.lang.Object
modernfeatures.streams.StreamBasicsPrintNamesAlpha

public class StreamBasicsPrintNamesAlpha extends Object
Demonstrates the use of Java 8 Streams and functional interfaces to process a list of names.

This example showcases how to:

  • Create a Stream from a List
  • Use Predicate for filtering names
  • Use Function for mapping/transformation
  • Use Consumer for processing/output
  • Chain intermediate operations (filter, map, sorted)
  • Trigger terminal operation (forEach)
The stream pipeline prints all names longer than 3 characters, in uppercase, sorted in alphabetical order.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
    Main method demonstrating the stream pipeline: Create a Stream from a list of names Filter names with length greater than 3 Convert each name to uppercase Sort the names alphabetically Print each name to the console

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StreamBasicsPrintNamesAlpha

      public StreamBasicsPrintNamesAlpha()
  • Method Details

    • main

      public static void main(String[] args)
      Main method demonstrating the stream pipeline:
      1. Create a Stream from a list of names
      2. Filter names with length greater than 3
      3. Convert each name to uppercase
      4. Sort the names alphabetically
      5. Print each name to the console
      Parameters:
      args - command-line arguments (not used)