Stream empty() in Java with Examples
Improve
Stream empty() creates an empty sequential Stream.
Syntax :
Output :
static <T> Stream<T> empty()Parameters :
- T : The type of stream elements.
- Stream : A sequence of objects that supports various methods which can be pipelined to produce the desired result.
// 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); } } |
No Output
Share your thoughts in the comments

