Java : Stream.Builder with Examples
Stream.Builder (Java SE 18 & JDK 18) API Examples.
You will find code examples on most Stream.Builder methods.
Summary
final var builder = Stream.<String>builder();
final var stream = builder.add("aaa").add("bbb").add("ccc").build();
System.out.println("-- forEach --");
stream.forEach(System.out::println);
// Result
// ↓
//-- forEach --
//aaa
//bbb
//ccc
Methods
void accept (T t)
final var builder = Stream.<String>builder();
builder.accept("aaa");
builder.accept("bbb");
builder.accept("ccc");
final var stream = builder.build();
System.out.println("-- forEach --");
stream.forEach(System.out::println);
// Result
// ↓
//-- forEach --
//aaa
//bbb
//ccc
default Stream.Builder<T> add (T t)
final var builder = Stream.<String>builder();
final var stream = builder.add("aaa").add("bbb").add("ccc").build();
System.out.println("-- forEach --");
stream.forEach(System.out::println);
// Result
// ↓
//-- forEach --
//aaa
//bbb
//ccc
Stream<T> build ()
Please see add(T t).
Methods declared in Consumer
Related posts
- API Examples