A very valuable property of functional interfaces is that they can be instantiated with lambdas. Here are some examples of lambdas:
On the left is a comma-separated input list of the specified type, and on the right is a code block with return:
(int x, int y) -> { return x + y; }
On the left is a comma-separated input list of the derived type , the right side is the return value:
(x, y) -> x + y
The left side is a single parameter of the derivation type, the right side is a return value:
x -> x * x
There is no input on the left side (official name: "burger arrow"), and it is returned on the right side A value:
() -> x
The left side is a single parameter of the deduced type, and the right side is a code block with no return value (return void):
x -> { System.out.println(x); }
Static method reference:
String::valueOf
Non Static method reference:
Object::toString
Inherited function reference:
x::toString
Constructor reference:
ArrayList::new
You can come up with some function reference formats that serve as shorthand for other lambda formats.