Stream empty() creates an empty sequential Stream.
static <T> Stream<T> empty()
- T : The type of stream elements.
- Stream : A sequence of objects that supports various methods which can be pipelined to produce the desired result.
Return Value : Stream empty() returns an empty sequential stream.
Note : An empty stream might be useful to avoid null pointer exceptions while callings methods with stream parameters.
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.