Challenge 1: Filter, Square, and Collect — Possible Solution ==================================================================== StreamDemo.java: import java.util.List; import java.util.stream.Collectors; public class StreamDemo { public static void main(String[] args) { List numbers = List.of(1, 2, 3, 4, 5, 6, 7, 8); List result = numbers.stream() .filter(n -> n % 2 == 0) .map(n -> n * n) .collect(Collectors.toList()); System.out.println(result); } } Output: [4, 16, 36, 64] Explanation: filter(n -> n % 2 == 0) keeps only even numbers (2, 4, 6, 8). map(n -> n * n) squares each surviving element. collect(Collectors.toList()) is the terminal operation -- nothing in the pipeline actually runs until this call, at which point every element flows through filter then map in sequence, and the final results are gathered into a new List. A method reference wasn't used here since squaring isn't an existing single method call the way String::toUpperCase was in the chapter's own example -- n -> n * n has no equivalent method to reference. WHY THIS WORKS AS AN ANSWER ------------------------------ This builds the exact filter-then-map-then-collect pipeline shape the chapter introduces, and correctly recognizes that squaring has no existing method to reference, so a lambda is the right and only choice there, while still noting where a method reference would apply if the operation were different.