June 2025
Intermediate to advanced
1129 pages
53h
English
So far, much of this section has been spent introducing types from the java.util.function package, the functional interfaces developers can use to express mappings in Java. Now let’s talk more generally about functional programming and its advantages.
First, functions provide an additional level of code reusability. Consider the following predicate:
Predicate<Path> exists = path -> Files.exists( path );
This exists predicate is relatively simple and also omits exception handling. But of course you could write something more complex. The point is that these predicates can be reused in all sorts of places, such as for filtering in lists or deleting items from lists. The predicate can ...
Read now
Unlock full access