Last Updated : 11 Jul, 2025
Stream empty()creates an empty sequential Stream.
Syntax :static <T> Stream<T> empty()Parameters :
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.
Example : Java
// Java code for Stream empty()
import java.util.*;
import java.util.stream.Stream;
class GFG {
// Driver code
public static void main(String[] args)
{
// Creating an empty Stream
Stream<String> stream = Stream.empty();
// Displaying elements in Stream
stream.forEach(System.out::println);
}
}
Output :
No Output
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4