Java Lambda - LongUnaryOperator example








LongUnaryOperator represents an operation on a single long-valued operand that produces a long-valued result. This is the primitive type specialization of UnaryOperator for long.

Method

  1. LongUnaryOperator applyAsLong
  2. LongUnaryOperator compose
  3. LongUnaryOperator andThen
  4. LongUnaryOperator identity




Example

The following example shows how to use LongUnaryOperator.

import java.util.function.LongUnaryOperator;
//from  w  w w .j  av a 2  s. com
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.