Skip to content

Instantly share code, notes, and snippets.

@holograph
Created October 14, 2018 08:48
Show Gist options
  • Save holograph/7ee22eb1c1cad61b5d3957673b1dc3d9 to your computer and use it in GitHub Desktop.
Save holograph/7ee22eb1c1cad61b5d3957673b1dc3d9 to your computer and use it in GitHub Desktop.
Showcasing Java method references
import java.util.function.Supplier;
class A {
static int staticSupplier() { return 5; }
int instanceSupplier() { return 10; }
static void printOut(Supplier<Integer> supplier) {
System.out.println(supplier.get());
}
public static void main(String[] args) {
A a = new A();
printOut(A::staticSupplier);
printOut(a::instanceSupplier);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment