LongStream empty() method in Java

Java 8Object Oriented ProgrammingProgramming

The empty() method of the LongStream class in Java returns an empty sequential LongStream.

The syntax is as follows.

static LongStream empty()

To use the LongStream class in Java, import the following package.

import java.util.stream.LongStream;

The following is an example to implement LongStream empty() method in Java.


 Live Demo

import java.util.stream.LongStream;
public class GFG {
   public static void main(String[] args) {
      LongStream longStream = LongStream.empty();
      System.out.println("The count of elements in the stream: "+longStream.count());


The count of elements in the stream: 0
Updated on 30-Jul-2019 22:30:25