17.8 Functional Interfaces
[This section requires the interface concepts introduced in Sections 10.9–10.10.]
Section 10.10 introduced Java SE 8’s enhanced interface features—default
methods and static
methods—and discussed the concept of a functional interface—an interface that contains exactly one abstract
method (and may also contain default
and static
methods). Such interfaces are also known as single abstract method (SAM) interfaces. Functional interfaces are used extensively in functional-style Java programming. Functional programmers work with so-called pure functions that have referential transparency—that is, they:
-
depend only on their parameters
-
have no side-effects and
-
do not maintain any state.
In Java, pure functions are methods ...
Get Java How to Program, Early Objects, 11th Edition 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.