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
What is the IntStream.Builder accept() method in Java
Insert an element into IntStream using the IntStream.Builder accept() method. It adds element to the stream being built.
The syntax is as follows:
void accept(int t)
Here, parameter t is the input argument.
The elements are inserted as shown below in the stream:
builder.accept(10); builder.accept(15); builder.accept(25); builder.accept(39); builder.accept(45);
The following is an example to implement IntStream.Builder accept() 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 of the stream...");
builder.accept(10);
builder.accept(15);
builder.accept(25);
builder.accept(39);
builder.accept(45);
builder.accept(55);
builder.accept(80);
builder.build().forEach(System.out::println);
}
}
output
Elements of the stream... 10 15 25 39 45 55 80
Advertisements
