In this lecture, we examine how to perform collection transformation imperatively: turning
List<String> into
List<Integer> (for example, string lengths), how to extract fields from domain model objects (
Product → name/price), how to “flatten” nested collections via
addAll() or nested loops, and how to combine filtering with transformation using
if and methods like
startsWith. We will finish by reviewing common mistakes: mutating the source collection, incorrect casts (
ClassCastException), and performance considerations.