The relationship between the JAVA8 function reference and the lambda expression => function Reference is a simplified lambda expression that infers only the function, parameter, and return value compiler that appears.
> Actually this grammar and lambda expression is exactly the opposite,  LAMBDA expression represents an anonymous method, which is the absence of a function name, giving only parameters and method bodies. Then the existing function comes in handy, the existing function has the method name, gives the method name, the parameters and the method body have already, by the compiler inferred.
Note: Methods in Java cannot exist independently and must be included in the type, which is the limit @FunctionalInterface the lambda expression.
Recall that we can think the lambda expressions as methods that don ' t has names.
Now, the consider this lambda expression:
In real code this would probably is shorter because of type inference
(MyObject myObj), myobj.tostring ()
This is being autoconverted to an implementation of a @FunctionalInterface that
Have a single nondefault method, takes a single MyObject and returns String.
However, this seems like excessive boilerplate, and so Java 8 provides a syntax for
Making this easier to read and write:
Myobject::tostring
This is a shorthand, known as a method reference, which uses an existing method as a
Lambda expression. It can be thought of as using a existing method, but ignoring
The name of the method, so it is can used as a lambda, and autoconverted in the
Usual.
JAVA8 Method References-java In a nutshell, 6th