Java Lambda - DoubleFunction apply example








DoubleFunction apply applies passed-in function to the given argument.

Syntax

apply has the following syntax.

R apply(double value)

Example

The following example shows how to use apply.

import java.util.function.DoubleFunction;
//from   ww w . j a v a 2s .  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.