Java Lambda - ToDoubleFunction applyAsDouble example








ToDoubleFunction applyAsDouble applies this function to the given argument.

Syntax

applyAsDouble has the following syntax.

double applyAsDouble(T value)

Example

The following example shows how to use applyAsDouble.

import java.util.function.ToDoubleFunction;
//from  w w w  .j ava 2s . c om
public class Main {

  public static void main(String[] args) {
    ToDoubleFunction<Integer> i  = (x)-> Math.sin(x);
    
    System.out.println(i.applyAsDouble(Integer.MAX_VALUE));
  }
}

The code above generates the following result.