DoubleStream.Builder accept() method in Java

Java 8Object Oriented ProgrammingProgramming

The accept() method of the DoubleStream class in Java adds an element to the stream being built.

The syntax is as follows −

void accept(double ele)

Here, ele is the element to be inserted into the stream.

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() accept() 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.accept(12.9);
      builder.accept(25.6);
      builder.accept(35.8);
      builder.accept(43.9);
      builder.accept(56.3);
      builder.accept(67.4);
      builder.accept(78.8);
      builder.accept(89.4);
      builder.build().forEach(System.out::println);
   }
}

Output

12.9
25.6
35.8
43.9
56.3
67.4
78.8
89.4
raja
Updated on 30-Jul-2019 22:30:25

Advertisements