Method and Constructor references by using :: (double colon) operator

 

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 return type, method name, modifiers etc. are not required to match.

 

Syntax:

Case1:

If our specified method is static method

classname::methodName

 

Case2:

If the method name is instance method

objRef::methodName

 

Functional Interface can refer lambda expression and Functional Interface can also refer method reference. Hence lambda expression can be replace with method reference.

Hence method reference is alternative syntax to lambda expression.


Google Script for Data Entry Form in Google Spreadsheet

// function to validate the entry made by user in user form function validateEntry (){ // declare a variable and referernece of active goog...