IntStream empty() in Java with examples
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.
import java.util.*;
import java.util.stream.IntStream;
class GFG {
public static void main(String[] args) {
IntStream stream = IntStream.empty();
System.out.println(stream.count());
}
}
|
Output :
0
Example 2 : Creating empty LongStream.
import java.util.*;
import java.util.stream.LongStream;
class GFG {
public static void main(String[] args) {
LongStream stream = LongStream.empty();
System.out.println(stream.count());
}
}
|
Output :
0
Last Updated :
06 Dec, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...