Skip to content

Instantly share code, notes, and snippets.

@dlhartveld
Last active December 14, 2015 08:18
Show Gist options
  • Save dlhartveld/5056361 to your computer and use it in GitHub Desktop.
Save dlhartveld/5056361 to your computer and use it in GitHub Desktop.
An example of JDK8 functional interfaces.
// 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