Double colon (
::
) operator is used to get a method reference in Java.You can use it, for example, to pass a static method as a parameter:
public class Example {
public static void main(String[] args) {
// 0.5984721441039564
transformAndPrint(2.5D, Math::sin);
// 2.0
transformAndPrint(2.5D, Math::floor);
}
public static void transformAndPrint(
Double value,
java.util.function.Function<Double, Double> transformer
) {
System.out.println(transformer.apply(value));
}
}