Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 788 Bytes

File metadata and controls

35 lines (27 loc) · 788 Bytes

Structure of a Stream Pipeline

Every stream expression follows the same three-part structure:

Source  →  Zero or more intermediate operations  →  One terminal operation
var result = List.of(5, 3, 8, 1, 9, 2).stream()   // 1. source
        .filter(n -> n > 3)                        // 2. intermediate
        .sorted()                                  // 2. intermediate
        .toList();                                 // 3. terminal

System.out.println(result);

Output

[5, 8, 9]

Previous: D Primitive Streams.md Next: F Stream Vs Collection.md