
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
The Build Method in Java LongStream Builder
The build() method of the LongStream.Builder class builds the stream and returns the built stream. The following is the syntax:
LongStream build()
Import the following package for the LongStream.Builder class in Java:
import java.util.stream.LongStream;
Declare a LongStream.Builder and add elements:
LongStream.Builder builder = LongStream.builder(); builder.add(24000L); builder.add(47470L); builder.add(12999L);
Now, use the build() method to build the stream:
builder.build()
The following is an example displaying how to implement build() method of LongStream.Builder in Java:
Example
import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream.Builder builder = LongStream.builder(); builder.add(24000L); builder.add(47470L); builder.add(12999L); builder.add(55757L); builder.add(12999L); builder.add(55757L); builder.build().forEach(System.out::println); } }
output
24000 47470 12999 55757 12999 55757
Advertisements