DoubleStream.Builder add(double t) example

Description

DoubleStream.Builder add(double t) adds an element to the stream being built.

Syntax

add has the following syntax.


default DoubleStream.Builder add(double t)

Example

The following example shows how to use add.


import java.util.stream.DoubleStream;
/*from  w ww  .  j a v  a 2  s  .c  om*/
public class Main {
  public static void main(String[] args) {
    DoubleStream.Builder b = DoubleStream.builder();
    b.add(1.1)
     .add(2.2)
     .add(3.3)
     .add(4.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