Java Lambda - LongUnaryOperator identity example








Returns a unary operator that always returns its input argument.

Syntax

identity has the following syntax.

static LongUnaryOperator identity()

Example

The following example shows how to use identity.

import java.util.function.LongUnaryOperator;
//from w  w w.j a va  2  s .co m
public class Main {

  public static void main(String[] args) {
    LongUnaryOperator i = LongUnaryOperator.identity();
    
   
    System.out.println(i.applyAsLong(Long.MAX_VALUE));
  }
}

The code above generates the following result.