Intermediate operations transform a stream into another stream. They are lazy: calling filter or map only records a step in the pipeline. No element is processed until a terminal operation runs. If a pipeline has no terminal operation, none of its lambdas are ever executed, which is why a question with only peek(System.out::println) and no terminal operation prints nothing.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 6 more sections, 5 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.