- 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 sequential() method in Java
The sequential() method of the LongStream class in Java returns an equivalent stream that is sequential.
The syntax is as follows −
LongStream sequential()
To use the LongStream class in Java, import the following package −
import java.util.stream.LongStream;
Create a LongStream and add some elements −
LongStream longStream = LongStream.of(50L, 70L, 100L, 150L, 200L, 300L);
Now, return an equivalent stream that is sequential −
LongStream res = longStream.sequential();
The following is an example to implement LongStream sequential() method in Java −
Example
import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.of(50L, 70L, 100L, 150L, 200L, 300L); LongStream res = longStream.sequential(); res.forEach(System.out::println); } }
Output
50 70 100 150 200 300
Advertisements