Java Lambda - IntFunction example

IntFunction represents a function that accepts an int-valued argument and produces a result. This is the int-consuming primitive specialization for Function.


  1. IntFunction apply


The following example shows how to use IntFunction.

import java.util.function.IntFunction;
// ww w .jav  a 2 s  . c  o m
public class Main {

  public static void main(String[] args) {
    IntFunction<String> i = (x)->Integer.toString(x);


The code above generates the following result.