- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
LongStream.Builder accept() method in Java
The accept() method of the LongStream.Builder class adds an element to the stream being built.
The syntax is as follows
void accept(long i)
Here, i is the input.
To use the LongStream.Builder class in Java, import the following package
import java.util.stream.LongStream;
Create a LongStream
LongStream.Builder builder = LongStream.builder();
Add some elements
builder.accept(200L); builder.accept(600L); builder.accept(400L);
The following is an example to implement LongStream.Builder accept() method in Java
Example
import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream.Builder builder = LongStream.builder(); builder.accept(200L); builder.accept(600L); builder.accept(400L); builder.accept(350L); builder.accept(900L); builder.accept(850L); builder.accept(1200L); builder.accept(1500L); builder.build().forEach(System.out::println); } }
Output
200 600 400 350 900 850 1200 1500
Advertisements
To Continue Learning Please Login
Login with Google