Java Lambda - DoubleFunction example








DoubleFunction represents a function that accepts a double-valued argument and produces a result. This is the double-consuming primitive specialization for Function.

Method

  1. DoubleFunction apply

Example

The following example shows how to use DoubleFunction.

import java.util.function.DoubleFunction;
// w w w.  j  av a 2 s . c o m
public class Main {

  public static void main(String[] args) {
    DoubleFunction<String> df = (d) -> d +" is now a string";

    System.out.println(df.apply(0.5));

  }
}

The code above generates the following result.