Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

IntStream empty() in Java with examples

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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

static <T> Stream<T> empty()

Where, T is the type of stream elements,
and the function returns an empty sequential stream.

Example 1 : Creating empty IntStream.




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

Output :

0

Example 2 : Creating empty LongStream.




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

Output :

0

My Personal Notes arrow_drop_up
Last Updated : 06 Dec, 2018
Like Article
Save Article
Similar Reads
Related Tutorials