Stream.Builder add(T t)
adds an element to the stream being built.
add
has the following syntax.
default Stream.Builder<T> add(T t)
The following example shows how to use add
.
import java.util.stream.Stream; //from ww w .java2s. com public class Main { public static void main(String[] args) { Stream.Builder<String> b = Stream.builder(); b.add("a"); b.add("b"); b.add("c"); b.add("d"); b.add("e"); Stream<String> s = b.build(); s.forEach(System.out::println); } }
The code above generates the following result.