Stream Builder
Description
We can use Stream.Builder<T>
to create streams.
The following code creates a stream builder.
Stream.Builder<String> builder = Stream.builder();
Example
import java.util.stream.Stream;
// ww w.ja v a 2 s . c o m
public class Main {
public static void main(String[] args) {
Stream<String> stream = Stream.<String>builder()
.add("XML")
.add("Java")
.add("CSS")
.add("SQL")
.build();
stream.forEach(System.out::println);
}
}
The code above generates the following result.