Java Lambda - ToIntFunction example

ToIntFunction represents a function that produces an int-valued result. This is the int-producing primitive specialization for Function.


  1. ToIntFunction applyAsInt


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);

The code above generates the following result.