Method References by the Double-colon Separator :: in Java
The double-colon separator :: has been available since Java 8. The purpose is to provide a way to refer to a method without executing it . Method reference is similar to the sense of Lambda expression in that it requires a target method that fits in a functional interface. Procedural programming requires passing variables or objects as parameters. Now with method references, we can pass a method as a parameter. The double-colon :: separator allows references to static methods or instance methods. The syntax of both is similar. The below example demonstrates the use of method references to static methods. import java.util.function.*; class MyTools { // This class contains some simple static methods. static String changeI2We (String s) { return s.replaceAll( "I" , "we" ); } static String addAuthor (String s) { return s + " -- Calmalgo" ; } static Integer countWords (String s...