Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
DoubleStream.Builder add() method in Java
The add() method of the DoubleStream.Builder class in Java adds an element to the stream being built. The method returns this builder.
The syntax is as follows
default DoubleStream.Builder add(double ele)
Here, ele is the element to be added to this stream.
To use the DoubleStream.Builder class in Java, import the following package
import java.util.stream.DoubleStream; Create DoubleStream.Builder: DoubleStream.Builder builder = DoubleStream.builder(); Now add some elements: builder.add(23.5); builder.add(33.1); builder.add(35.6); builder.add(53.1);
The following is an example to implement DoubleStream.Builder add() method in Java
Example
import java.util.stream.DoubleStream;
public class Demo {
public static void main(String[] args) {
DoubleStream.Builder builder = DoubleStream.builder();
builder.add(23.5);
builder.add(33.1);
builder.add(35.6);
builder.add(53.1);
builder.add(36.8);
builder.add(77.4);
builder.add(88.2);
builder.add(68.9);
builder.build().forEach(System.out::println);
}
}
Output
23.5 33.1 35.6 53.1 36.8 77.4 88.2 68.9
Advertisements
