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
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- IntStream distinct() in Java with examples
- IntStream peek() in Java with examples
- IntStream average() in Java with Examples
- IntStream max() in Java with examples
- IntStream min() in Java with Examples
- IntStream count() in Java with examples
- IntStream filter() in Java with examples
- IntStream anyMatch() in Java with examples
- IntStream allMatch() in Java with examples
- IntStream noneMatch() in Java with examples
- IntStream reduce(int identity, IntBinaryOperator op) in Java with Examples
- IntStream reduce(IntBinaryOperator op) in Java with Examples
- IntStream toArray() in Java with Examples
- IntStream.Builder build() in Java with Examples
- IntStream codePoints() method in Java with Examples
- IntStream findAny() with examples
- java.util.stream.IntStream/LongStream | Search an element
- IntStream iterator() in Java
- IntStream rangeClosed() in Java
- IntStream map(IntUnaryOperator mapper) in Java
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.

