LongUnaryOperator applyAsLong example

Description

LongUnaryOperator applyAsLong applies this operator to the given operand.

Syntax

applyAsLong has the following syntax.


long applyAsLong(long operand)

Example

The following example shows how to use applyAsLong.


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

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

The code above generates the following result.