Skip to content
Related Articles

Related Articles

DoubleStream empty() in Java with examples
  • Last Updated : 06 Dec, 2018

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 :




// 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());
    }
}
Output:
0

Example 2 :




// 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()));
    }
}
Output:
[]

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :