The double colon operator definition in Java
The double-colon operator is a handle to a class method, a shorthand for a lambda expression called eta-conversion or η-conversion.
The usual case:
Simplify X-System.out.println (x) to System.out: The process of:p Rintln is called eta-conversion
The process of simplifying System.out::p rintln to X, System.out.println (x) is called Eta-expansion
Paradigm:
Class Name:: Method Name
Attention:
- method is not followed by ()
- Lazy Load method is called to see caller usage
Using the example method call
Person--person.getage ();
Can replace
Person::getage
X-System.out.println (x)
Can replace
System.out::p rintln
Out is an object of the PrintStream class, and println is the method of the class that overloads the method based on the type of X
Creating objects
(), New arraylist<> ();
can be replaced by
Arraylist::new
The New keyword actually calls the construction method of the ArrayList
JVM implementation
The JVM's underlying implementation is callsite, and the interface to the JDK layer burst is functional
Reference
http://hongjiang.info/eta-conversion-and-eta-expansion/
Java:: Double colon operator in Java