Java Reference
In-Depth Information
The functional interface here takes one ActionEvent parameter and doesn't return anything
( void ), but functional interfaces can come in many kinds. For example, they may take two
parameters and return a value. They can also use generics; it just depends upon what you
want to use them for.
From now on, I'll use diagrams to represent the different kinds of functional interfaces
you're encountering. The arrows going into the function represent arguments, and if there's
an arrow coming out, it represents the return type. For example, an ActionListener would
look like Figure 2-1 .
Figure 2-1. The ActionListener interface showing an ActionEvent going in and nothing (void) com-
ing out
Over time you'll encounter many functional interfaces, but there is a core group in the Java
Development Kit (JDK) that you will see time and time again. I've listed some of the most
important functional interfaces in Table 2-1 .
Table 2-1. Important functional interfaces in Java
Interface name
Arguments Returns Example
Has this album been released yet?
Predicate<T>
T
boolean
Printing out a value
Consumer<T>
T
void
Get the name from an Artist object
Function<T,R>
T
R
None
A factory method
Supplier<T>
T
Logical not ( ! )
UnaryOperator<T>
T
T
Multiplying two numbers ( * )
BinaryOperator<T> (T, T)
T
Search WWH ::




Custom Search