DoubleFunction is a functional interface that accepts one argument of type double and returns back a result. The interface contains one method, i.e, apply.
The DoubleFunction interface is defined in the java.util.function package. To import the DoubleFunction interface, check the following import statement.
import java.util.function.DoubleFunction;
apply(double value)This method applies the function to the given argument of type double. This is the functional method of the interface.
The syntax of the apply method is given below.
R apply(double value);
double value: The function argument of type double.R: The return type of the function.The method returns a value of type R.
import java.util.function.DoubleFunction;public class Main{public static void main(String[] args) {DoubleFunction<String> stringDoubleFunction = (d) -> String.format("The passed value is %s", d);double d = 100.3;// calling apply method of the DoubleFunctionSystem.out.println(stringDoubleFunction.apply(d));}}
DoubleFunction interface that accepts a double argument and returns a string.double value called d.apply() method with d as the argument and print the result to the console.