Java Lambda - DoubleToIntFunction example

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.


  1. DoubleToIntFunction applyAsInt


The following example shows how to use DoubleToIntFunction.

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

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


The code above generates the following result.