Skip to content

Lambdas

  1. Make a copy of your PresidentAppInnerClasses.java (so you can keep the original for reference), and name the new copy PresidentAppLambda.java.

  2. Make sure the new class's main instantiates a PresidentAppLambda, not PresidentAppInnerClasses.

  3. In the new copy, replace all inner classes with Lambda expressions.

  4. Start by replacing anonymous classes, then replace local and member class instantiations.

  5. Remove any local or member class definitions from your class.

  6. Update any remaining sort or filter calls to use lambdas.

  7. Modify filter to use BiPredicate instead of PresidentMatcher.

Stretch Goals

  1. If you haven't already, create a method that takes a list of presidents and writes it as tab-separated values to a file.

  2. Records should be formatted so the existing code would be able to read and parse the records.

  3. When testing, be careful NOT to use resources/presidents.tsv as the output file!

  4. Pass filtered lists and filenames to this method to save files with the presidents from each party.


Up