Last active
December 14, 2015 08:18
-
-
Save dlhartveld/5056361 to your computer and use it in GitHub Desktop.
An example of JDK8 functional interfaces.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Existing interfaces that are now considered functional interfaces: | |
interface java.lang.Runnable { | |
void run(); | |
} | |
interface java.util.concurrent.Executor { | |
void execute(java.lang.Runnable command); | |
} | |
interface java.lang.Iterable<T> { | |
java.util.Iterator<T> iterator(); | |
} | |
interface java.awt.event.ActionListener { | |
void actionPerformed(java.awt.event.ActionEvent e); | |
} | |
// New functional interfaces: | |
interface java.util.function.Consumer<T> { | |
void accept(T t); | |
} | |
interface java.util.function.Function<T, R> { | |
R applly(T t); | |
} | |
interface java.util.function.Predicate<T> { | |
boolean test(T t); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment