ToIntFunction represents a function that produces an int-valued result. This is the int-producing primitive specialization for Function.
The following example shows how to use ToIntFunction
.
import java.util.function.ToIntFunction; /*ww w. j a va 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.