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.


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


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;

The code above generates the following result.