IntToDoubleFunction is a functional interface that accepts an integer and returns a double. The interface contains one method: applyAsDouble.
The IntToDoubleFunction interface is defined in the java.util.function package. To import the IntToDoubleFunction interface, check the following import statement.
import java.util.function.IntToDoubleFunction;
applyAsDouble(int value) methodThis method applies the function to the given integer and produces a double. This is the functional method of the interface.
double applyAsDouble(int value)
int value - A function argument of type integer.The method returns the function result of type double.
import java.util.function.IntToDoubleFunction;public class Main{public static void main(String[] args) {// Implementation of IntToDoubleFunction interface that returns square of the int valueIntToDoubleFunction intToDoubleFunction = value -> value * value;int value = 34;// calling applyAsDouble method of IntToDoubleFunctionSystem.out.println(intToDoubleFunction.applyAsDouble(value));}}
In the above code, we create an implementation of the IntToDoubleFunction interface that accepts an integer as an argument and returns the square of the argument as a double value.