Challenge 2: A Pipeline With No Terminal Operation — Possible Solution ==================================================================== LazyDemo.java: import java.util.List; public class LazyDemo { public static void main(String[] args) { List names = List.of("Alice", "Bob", "Carol"); names.stream() .filter(n -> { System.out.println("Checking: " + n); return n.length() > 3; }); // No output at all appears above this comment when run. // filter() is an intermediate operation -- it only ever // DESCRIBES a step in the pipeline, it never actually // executes it. Nothing forces the stream to run its // elements through that filter, because no terminal // operation (collect, forEach, reduce, etc.) was ever // called. The lambda inside filter() -- including its // println side effect -- is simply never invoked. System.out.println("Program finished."); } } Output: Program finished. WHY THIS WORKS AS AN ANSWER ------------------------------ This reproduces the chapter's own lazy-evaluation example exactly -- a filter with a print side effect and no terminal operation -- and the comment correctly identifies that the absence of any terminal operation is the reason the filter's lambda body, print included, never runs at all.