Search code examples
javajava-stream

Java Streams Terminology - Difference between intermediate - non terminal


When I am reading tutorials on Java Stream API (Java Platform SE 8) I see some mentions like terminal operations and non-terminal operations.

Is the term "non-terminal operations" same thing as the "intermediate operations"?


Solution

  • 'Non-terminal' is not really defined but I might use it to cover both 'intermediate' operations and 'source' expressions such as

    Stream.of("foo")
    

    While 'intermediate' is referring to neither the start nor the terminal operations, e.g.

    .peak(() -> {/*...*/})