Java Lambda - ToDoubleFunction example








ToDoubleFunction represents a function that produces a double-valued result. This is the double-producing primitive specialization for Function.

Method

  1. ToDoubleFunction applyAsDouble

Example

The following example shows how to use ToDoubleFunction.

import java.util.function.ToDoubleFunction;
//from   w w w .j  a  v a2  s.  c  o m
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.