DoubleStream empty() in Java with examples

DoubleStream empty() is a method in java.util.stream.DoubleStream. This method returns an empty sequential DoubleStream.
Syntax :

static DoubleStream empty()

Where, DoubleStream is a sequence of primitive double-valued
elements and the function returns an empty sequential stream.

Example 1 :

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java code for DoubleStream empty()
import java.util.*;
import java.util.stream.DoubleStream;
  
class GFG {
  
    // Driver code
    public static void main(String[] args)
    {
        // creating an empty DoubleStream, a sequence of
        // primitive double-valued elements
        DoubleStream stream = DoubleStream.empty();
  
        // Displaying an empty sequential stream
        System.out.println(stream.count());
    }
}

chevron_right


Output:

0

Example 2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java code for DoubleStream empty()
import java.util.*;
import java.util.stream.DoubleStream;
  
class GFG {
  
    // Driver code
    public static void main(String[] args)
    {
  
        // creating an empty DoubleStream, a sequence of
        // primitive double-valued elements
        DoubleStream stream = DoubleStream.empty();
  
        // Displaying an empty sequential stream
        System.out.println(Arrays.toString(stream.toArray()));
    }
}

chevron_right


Output:

[]


My Personal Notes arrow_drop_up

In love with a semicolon because sometimes i miss it so badly)

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.