Java Lambda - DoubleUnaryOperator identity example

DoubleUnaryOperator identity returns a unary operator that always returns its input argument.


identity has the following syntax.

static DoubleUnaryOperator identity()


The following example shows how to use identity.

import java.util.function.DoubleUnaryOperator;
//from w  ww .  ja va 2 s .  c  om
public class Main {

  public static void main(String[] args) {
    DoubleUnaryOperator id = DoubleUnaryOperator.identity();

The code above generates the following result.