Java Streams - LongStream empty() example








LongStream empty() returns an empty sequential LongStream.

Syntax

empty has the following syntax.

static LongStream empty()

Example

The following example shows how to use empty.

import java.util.stream.LongStream;

public class Main {
  public static void main(String[] args) {
    LongStream b = LongStream.empty();

    System.out.println(b.count());
  }
}

The code above generates the following result.