IntStream.Builder accept(int t) example

Description

IntStream.Builder accept(int t) adds an element to the stream being built.

Syntax

accept has the following syntax.


void accept(int t)

Example

The following example shows how to use accept.


import java.util.stream.IntStream;
//from  www  .  j  a va  2 s  . c om
public class Main {
  public static void main(String[] args) {
    IntStream.Builder b = IntStream.builder();
    b.accept(1);
    b.accept(2);
    b.accept(3);
    b.accept(4);
    
    b.build().forEach(System.out::println);
  }
}

The code above generates the following result.





















Home »
  Java Streams »
    Reference »




Collectors
DoubleStream
DoubleStream.Builder
IntStream
IntStream.Builder
LongStream
LongStream.Builder
Stream
Stream.Builder