In this lecture, we’ll cover practical techniques for working with collections: searching for elements using
contains,
indexOf,
lastIndexOf, conditional search with a
for loop and the
break statement, finding the minimum and maximum with the
Collections class. We’ll practice sorting lists with
Collections.sort and
List.sort, using a
Comparator, sorting key–value pairs from a
Map, as well as sorting objects by a field. Finally, we’ll discuss common pitfalls: immutable lists from
List.of, attempts to sort a
Set/
Map, and incorrect comparators.