The :: operator refers to a method reference. A method reference is a simplified way of writing a lambda expression in order to call a method. Method references allow you to call a method by mentioning its name. The syntax for a method reference is as follows: COPY Object :: methodName There are four ways to use a method reference: A method reference to a static method. A method reference to an instance method of an object. A method reference to instance methods of an arbitrary object of a particular type. A method reference to a constructor. METHOD REFERENCE TO A STATIC METHOD Let's take a look at the code snippet below: COPY import java.util.function.BiFunction; class Maths { public static int printAddition( int x, int y){ return x + y; } } public class Main { public static void main( String [] args) { BiFunction< Integer , Integer , Integer > addition = Maths::printAddition; int result = addition.apply(...
Your ultimate guide to mastering job interviews with expert tips, practice questions, and career advice