LongFunction
is a functional interface that accepts one argument of type long
and returns back a result. The interface contains one method, apply
.
The LongFunction
interface is defined in the java.util.function
package. To import the LongFunction
interface, check the following import statement.
import java.util.function.LongFunction;
apply(long value)
methodThis method applies the functionality to the given argument of type long
. This is the functional method of the interface.
R apply(long value);
long value
: This is the function argument of type long
.The method returns the function result.
import java.util.function.LongFunction;public class Main{public static void main(String[] args) {LongFunction<String> stringLongFunction = (d) -> String.format("The passed value is %s", d);long l = 100;// calling apply method of the LongFunctionSystem.out.println(stringLongFunction.apply(l));}}
LongFunction
interface.LongFunction
interface called stringLongFunction
that returns a string.l
.apply()
method passing l
as an argument.