In Java 8, what is Method Reference?

 Method reference is a compact way of referring to a method of functional interface. It is used to refer to a method without invoking it. :: (double colon) is used for describing the method reference. The syntax is class::methodName

For e.g.: 

Integer::parseInt(str) \\ method reference

str -> Integer.ParseInt(str); \\ equivalent lambda


CONVERSATION

0 Comments:

Post a Comment