- Trending Categories
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 concat() method in Java
The concat() method of the DoubleStream class creates a stream which is concatenated. The elements of the resultant stream are all the elements of the first stream followed by all the elements of the second stream.
The syntax is as follows.
static DoubleStream concat(DoubleStream streamOne, DoubleStream streamTwo)
Here, streamOne is the first stream whereas streamTwo is the second stream.
To use the DoubleStream class in Java, import the following package.
import java.util.stream.DoubleStream;
Create a DoubleStream with some elements.
DoubleStream doubleStream1 = DoubleStream.of(20.5, 30.6, 58.9, 66.7);
Create another DoubleStream.
DoubleStream doubleStream2 = DoubleStream.of(71.8, 77.9, 82.3, 91.6, 98.4);
Now, concat the streams
DoubleStream.concat(doubleStream1, doubleStream2)
The following is an example to implement DoubleStream concat() method in Java.
Example
import java.util.stream.DoubleStream; import java.util.stream.Stream; public class Demo { public static void main(String[] args) { DoubleStream doubleStream1 = DoubleStream.of(20.5, 30.6, 58.9, 66.7); DoubleStream doubleStream2 = DoubleStream.of(71.8, 77.9, 82.3, 91.6, 98.4); System.out.println("Concatenated Stream..."); DoubleStream.concat(doubleStream1, doubleStream2).forEach(a -> System.out.println(a)); } }
Output
Concatenated Stream... 20.5 30.6 58.9 66.7 71.8 77.9 82.3 91.6 98.4
Advertisements