Chapter 3Strings, Comparators, and Filters

Make everything as simple as possible, but not simpler.

Albert Einstein

The JDK has evolved to include convenience methods that promote the functional style. When using familiar classes and interfaces from the library—String, for example—we need to look for opportunities to use these newer functions in place of the old style. Also, anywhere we used an anonymous inner class with just one method, we can now use lambda expressions to reduce clutter and ceremony.

In this chapter we’ll use lambda expressions and method references to iterate over a String, to implement Comparators, to list files in a directory, and to observe file and directory changes. Quite a few methods introduced in the previous chapter ...

Get Functional Programming in Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.