Java Lambda - DoubleUnaryOperator applyAsDouble example








DoubleUnaryOperator applyAsDouble applies this operator to the given operand.

Syntax

applyAsDouble has the following syntax.

double applyAsDouble(double operand)

Example

The following example shows how to use applyAsDouble.

import java.util.function.DoubleUnaryOperator;

public class Main {

  public static void main(String[] args) {
    DoubleUnaryOperator dl = (x) -> {return x*x;};
    System.out.println(dl.applyAsDouble(3.14));
  }
}

The code above generates the following result.