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