Java Lambda - LongConsumer example








LongConsumer represents an operation that accepts a single long-valued argument and returns no result. This is the primitive type specialization of Consumer for long.

Method

  1. LongConsumer accept
  2. LongConsumer andThen




Example

The following example shows how to use LongConsumer.

import java.util.function.LongConsumer;

public class Main {

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

The code above generates the following result.