DoubleStream.Builder build() method in Java


The build() method of the DoubleStream.Builder class builds the stream. It transitions this builder to the built state.

The syntax is as follows

DoubleStream build()

To use the DoubleStream.Builder class in Java, import the following package

import java.util.stream.DoubleStream;

The following is an example to implement DoubleStream.Builder build() method in Java:

Example

 Live Demo

import java.util.stream.DoubleStream;
public class Demo {
   public static void main(String[] args) {
      DoubleStream.Builder builder = DoubleStream.builder();
      builder.add(34.5);
      builder.add(87.1);
      builder.add(35.6);
      builder.add(66.1);
      builder.add(36.8);
      builder.add(77.4);
      builder.add(88.2);
      builder.add(68.9);
      builder.build().forEach(System.out::println);
   }
}

Output

34.5
87.1
35.6
66.1
36.8
77.4
88.2
68.9

Updated on: 30-Jul-2019

62 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements