LongUnaryOperator identity example

Description

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  ww.  java  2s .  c om*/
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.