DoubleToIntFunction example

Description

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

Example

The following example shows how to use DoubleToIntFunction.


import java.util.function.DoubleToIntFunction;
/*from  w w w.  ja  v a 2 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.