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.


  1. LongConsumer accept
  2. LongConsumer andThen


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);;

The code above generates the following result.