DoubleUnaryOperator applyAsDouble example

Description

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;
//from   ww  w.  ja  v a2 s.  c o  m
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.