Java Streams - IntStream builder() example








IntStream builder() returns a builder for an IntStream.

Syntax

builder has the following syntax.

static IntStream.Builder builder()

Example

The following example shows how to use builder.

import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    IntStream i = IntStream.builder().add(0).build();
    i.forEach(System.out::println);  
  }
}

The code above generates the following result.