Stream.Builder build()
builds the stream, transitioning this builder to the built state.
build
has the following syntax.
Stream<T> build()
The following example shows how to use build
.
import java.util.stream.Stream; /*from ww w . ja v a 2s. c o m*/ public class Main { public static void main(String[] args) { Stream.Builder<String> b = Stream.builder(); b.accept("a"); b.accept("b"); b.accept("c"); b.accept("d"); b.accept("e"); Stream<String> s = b.build(); s.forEach(System.out::println); } }
The code above generates the following result.