A Little Sugar to Sweeten
We could implement all the ideas with what was already available in Java, but lambda expressions remove the ceremony and sweeten our efforts by adding a little syntax sugar. This quickly translates into code that’s faster to create and makes it easier to express our ideas.
In the past we’ve used a number of interfaces that only have single methods: Runnable, Callable, Comparable, and so on. These interfaces are common in the JDK library and often appear where just a single function is expected. All these existing library methods that expect a single method interface can now accept lightweight functions, thanks to the brilliant syntax sugar provided though functional interfaces.
A functional interface is an interface ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access