Java Lambda - IntToDoubleFunction example








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

Method

  1. IntToDoubleFunction applyAsDouble

Example

The following example shows how to use IntToDoubleFunction.

import java.util.function.IntToDoubleFunction;

public class Main {

  public static void main(String[] args) {
    IntToDoubleFunction i = (x) -> {return Math.sin(x);};
    System.out.println(i.applyAsDouble(2));
  }
}

The code above generates the following result.