Java Lambda - DoubleToIntFunction applyAsInt example








DoubleToIntFunction applyAsInt applies this function to the given argument.

Syntax

applyAsInt has the following syntax.

int applyAsInt(double value)

Example

The following example shows how to use applyAsInt.

import java.util.function.DoubleToIntFunction;
//from   w  ww . j av  a2  s.c o  m
public class Main {

  public static void main(String[] args) {
    DoubleToIntFunction df = (x) -> {return (int)x+2;};

   
    System.out.println(df.applyAsInt(3.14));
  }
}

The code above generates the following result.