ToDoubleFunction is a functional interface that accepts one argument and returns back a result of type double. The interface contains one method applyAsDouble().
The ToDoubleFunction interface is defined in the java.util.function package. To import the ToDoubleFunction interface check the following import statement.
import java.util.function.ToDoubleFunction;
The applyAsDouble(T value) method applies the function to the given argument and returns the result of type double. This is the functional method of the interface.
double applyAsDouble(T value);
T value: The function argument.The method returns the result of type double.
import java.util.function.ToDoubleFunction;public class Main{public static void main(String[] args) {ToDoubleFunction<Integer> convertSumToDouble = (i1) -> i1 + 5;Integer i1 = 5;// calling applyAsDouble method of the ToDoubleFunctionSystem.out.println(convertSumToDouble.applyAsDouble(i1));}}
In the code above, we create a ToDoubleFunction interface that accepts an integer argument and adds the integer 5 to the passed argument returning the result as a double value.