Java Lambda - LongUnaryOperator applyAsLong example








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;
//w ww.ja  v  a2  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.