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
IntStream.Builder add() method in Java
To insert element into the stream, you need to use the add() method of the IntStream.Builder.
The syntax is as follows:
default IntStream.Builder add(int t)
Here, parameter t is the element to be inserted.
Declare IntStream.Builder:
IntStream.Builder builder = IntStream.builder();
Add some elements to the Builder using add() method:
builder.add(10); builder.add(25); builder.add(33); builder.add(42);
The following is an example to implement IntStream.Builder add() method in Java
Example
import java.util.stream.IntStream;
public class Demo {
public static void main(String[] args) {
IntStream.Builder builder = IntStream.builder();
System.out.println("Elements in the stream...");
builder.add(10);
builder.add(25);
builder.add(33);
builder.add(42);
builder.add(55);
builder.add(68);
builder.add(75);
builder.build().forEach(System.out::println);
}
}
output
Elements in the stream... 10 25 33 42 55 68 75
Advertisements
