Java Reference
In-Depth Information
this sounds abstract; we now explain in detail what this means and what a functional interface
is.
3.2.1. Functional interface
Remember the interface Predicate<T> you created in
chapter 2
so you could parameterize the
behavior of the filter method? It's a functional interface! Why? Because Predicate specifies only
one abstract method:
public interface Predicate<T>{
boolean test (T t);
}
In a nutshell, a
functional interface
is an interface that specifies exactly one abstract method.
You already know several other functional interfaces in the Java API such as Comparator and
Note
You'll see in
chapter 9
that interfaces can now also have
default methods
(that is, a method with
a body that provides some default implementation for a method in case it isn't implemented by a
Search WWH ::
Custom Search