LongStream empty() method in Java


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.

Example

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

Output

The count of elements in the stream: 0

Updated on: 30-Jul-2019

70 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements