Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
DoubleStream empty() method in Java
The empty() method of the DoubleStream class in Java returns an empty sequential DoubleStream.
The syntax is as follows:
static DoubleStream empty()
To use the DoubleStream class in Java, import the following package:
import java.util.stream.DoubleStream;
Let us create an empty DoubleStream:
DoubleStream doubleStream = DoubleStream.empty();
Now, let us check the number of elements in the stream. It will be 0, since the stream is set to empty:
doubleStream.count()
The following is an example to implement DoubleStream empty() method in Java:
Example
import java.util.stream.DoubleStream;
public class Demo {
public static void main(String[] args) {
DoubleStream doubleStream = DoubleStream.empty();
System.out.println("Number of elements in the stream = "+doubleStream.count());
}
}
Here is the output. The result is 0 since the stream is set to empty:
Number of elements in the stream = 0
Advertisements
