Java Lambda - IntFunction apply example








IntFunction apply applies this function to the given argument.

Syntax

apply has the following syntax.

R apply(int value)

Example

The following example shows how to use apply.

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

  public static void main(String[] args) {
    IntFunction<String> i = (x)->Integer.toString(x);
    
    System.out.println(i.apply(3).length());

  }
}

The code above generates the following result.