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.

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
raja
Updated on 30-Jul-2019 22:30:25

Advertisements