- 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
DoubleStream sequential() method in Java
The sequential() method of the DoubleStream class returns an equivalent stream that is sequential.
The syntax is as follows
DoubleStream sequential()
To use the DoubleStream class in Java, import the following package
import java.util.stream.DoubleStream;
Create a DoubleStream and add some elements
DoubleStream doubleStream1 = DoubleStream.of(45.8, 67.9, 78.5, 90.6, 97.4);
Now create an equivalent stream that is sequential
DoubleStream doubleStream2 = doubleStream1.sequential();
The following is an example to implement DoubleStream sequential() method in Java
Example
import java.util.*; import java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { DoubleStream doubleStream1 = DoubleStream.of(45.8, 67.9, 78.5, 90.6, 97.4); DoubleStream doubleStream2 = doubleStream1.sequential(); System.out.println("Equivalent new stream..."); doubleStream2.forEach(System.out::println); } }
Output
Equivalent new stream... 45.8 67.9 78.5 90.6 97.4
Advertisements