Stream.Builder accept(T t)
adds an element to the stream being built.
accept
has the following syntax.
void accept(T t)
The following example shows how to use accept
.
import java.util.stream.Stream; /*w w w. j a va 2 s . com*/ 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.