DoubleStream builder() example

Description

DoubleStream builder() returns a builder for a DoubleStream.

Syntax

builder has the following syntax.


static DoubleStream.Builder builder()

Example

The following example shows how to use builder.


import java.util.stream.DoubleStream;
//w w w.  j  ava  2 s.  c  o m
public class Main {
  public static void main(String[] args) {
    DoubleStream.Builder b = DoubleStream.builder();
    b.accept(1.2);
    b.accept(1.2);
    b.accept(1.2);
    DoubleStream d = b.build();
    d.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