ToIntFunction example

Description

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

Example

The following example shows how to use ToIntFunction.


import java.util.function.ToIntFunction;
/*www .j av  a 2 s  .co 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.