Stream of(T t) example
Description
Stream of(T t)
creates a sequential Stream from a single element.
Syntax
of
has the following syntax.
static <T> Stream<T> of(T t)
Example
The following example shows how to use of
.
import java.util.stream.Stream;
// ww w . j a v a 2 s . c o m
public class Main {
public static void main(String[] args) {
Stream<String> s = Stream.of("a");
s.limit(10)
.forEach(System.out::println);
}
}
The code above generates the following result.