IntStream.Builder add(int t) example
Description
IntStream.Builder add(int t)
adds an element to the stream being built.
Syntax
add
has the following syntax.
default IntStream.Builder add(int t)
Example
The following example shows how to use add
.
import java.util.stream.IntStream;
/*from w ww .ja v a2s . co m*/
public class Main {
public static void main(String[] args) {
IntStream.Builder b = IntStream.builder();
b.add(1)
.add(2)
.add(3)
.add(4);
b.build().forEach(System.out::println);
}
}
The code above generates the following result.