
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
IntStream Builder Build Method in Java
The build() method builds the stream. It transitions the builder to the built state. It returns the built stream. First, add elements to the stream
IntStream.Builder builder = IntStream.builder(); builder.add(10); builder.add(25); builder.add(33);
Now the stream is in the built phase
builder.build().forEach(System.out::println);
The syntax is as follows
IntStream build()
The following is an example to implement IntStream.Builder build() 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