DoubleStream concat() method creates a concatenated stream in which the elements are all the elements of the first stream followed by all the elements of the second stream. The resulting stream is ordered if both of the input streams are ordered, and parallel if either of the input streams is parallel.
static DoubleStream concat(DoubleStream a, DoubleStream b)
- DoubleStream : A sequence of primitive double-valued elements.
- a : Represents the first stream.
- b : Represents the second stream.
Return Value : The function returns the concatenation of the two input DoubleStreams.
The calls to DoubleStream.concat(DoubleStream a, DoubleStream b) can be think of as forming a binary tree. The concatenation of all the input streams is at the root. The individual input streams are at the leaves. Below given is example for 3 DoubleStreams a, b and c.
Each additional input stream adds one layer of depth to the tree and one layer of indirection to reach all the other streams.
Note : The elements returned by DoubleStream.concat() method is ordered. For example, the following two lines returns the same result:
DoubleStream.concat(DoubleStream.concat(stream1, stream2), stream3); DoubleStream.concat(stream1, DoubleStream.concat(stream2, stream3));
But the result for the following two are different.
DoubleStream.concat(DoubleStream.concat(stream1, stream2), stream3); DoubleStream.concat(DoubleStream.concat(stream2, stream1), stream3);
Example 1 :
2.2 4.3 6.4 1.5 3.6 5.7
Example 2 :
2.2 4.3 6.4 1.5
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- DoubleStream.Builder build() in Java
- DoubleStream generate() method in Java
- DoubleStream forEach() method in Java
- DoubleStream forEachOrdered() method in Java
- DoubleStream sorted() in Java
- DoubleStream flatMap(DoubleFunction mapper) in Java
- DoubleStream summaryStatistics() in Java
- DoubleStream noneMatch() in Java with examples
- DoubleStream sum() in Java
- DoubleStream distinct() in Java with examples
- DoubleStream count() in Java with examples
- DoubleStream min() in Java with examples
- DoubleStream max() in Java with examples
- DoubleStream average() in Java with Examples
- DoubleStream filter() in Java with examples
- DoubleStream empty() in Java with examples
- DoubleStream skip() in Java
- DoubleStream iterator() in Java
- DoubleStream map(DoubleUnaryOperator mapper) in Java
- DoubleStream of() in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.