Functional Interface method can be mapped to our specified method by using :: (double colon)operator. This is called method reference. Our specified method can be either static method or instance method. Functional Interface method and our specified method should have same argument types, except this the remaining things like returntype, method name, modifiers etc are not required to match.
Syntax: Class Name :: Method Name
If the method is instance method: Obj ref::method Name
Functional Interface can refer lambda expression and Functional Interface can also refer method reference. Hence lambda expression can be replaced with method reference, hence method reference is alternative syntax to lambda expression.
With Lambda Expression-
With Method Reference
In the above example Runnable interface run() method referring to Test class static method method1(). Method reference to Instance method:
In the above example functional interface method ml () referring to Test class instance method m2(). The main advantage of method reference is we can use already existing code to implement functional interfaces(code reusability).
We can use :: (double colon) operator to refer constructors also
Syntax: classname :: name
Interf f = sample:: new; functional interface f referring sample class constructor.
Note: In method and constructor references compulsory the argument types must be matched.