Exercise Set 8: Anonymous Inner Classes (Lambda)

Exercise 8.1 The given code implements a list of Strings with four methods: count which counts the number of items in the list, using the traditional technique; mapStringToString and mapStringToBool, each of which creates a new list by applying the specified method to every item in the original list; and orMapString which returns true if one of the list items satisfied the given predicates. The last three methods take as argument an object which implements one of the two functional interfaces. The examples in the test suite illustrate the implementation which uses the anonymous inner classes.

Exercise 8.2 The given example sorts the list of Persons by their full names, first names, and by the year of birth, using the anonymous inner classes to implement the desired Comparator interface.
Using the same technique, first develop a list of CDs, where each CD has a title, artist name and the number of tracks. Implement three different ways of sorting this list: by titles, by artists, and by the number of tracks.