ToIntFunction applyAsInt example
Description
ToIntFunction applyAsInt applies this function to the given argument.
Syntax
applyAsInt
has the following syntax.
int applyAsInt(T value)
Example
The following example shows how to use applyAsInt
.
import java.util.function.ToIntFunction;
//from www . j a v a 2 s.c o m
public class Main {
public static void main(String[] args) {
ToIntFunction<String> i = (x)-> Integer.parseInt(x);
System.out.println(i.applyAsInt("2"));
}
}
The code above generates the following result.
Home »
Java Lambda »
java.util.function Reference »
Java Lambda »
java.util.function Reference »