LongStream sequential() in Java
LongStream sequential() returns a sequential LongStream. It may return itself, either because the stream was already sequential, or because the underlying stream state was modified to be sequential. LongStream sequential() is an intermediate operation. Intermediate operations are invoked on a Stream instance and after they finish their processing, they give a Stream instance as output.
Syntax :
LongStream sequential() Where, LongStream is a sequence of primitive long-valued element.
Example 1 :
// Java code for LongStream sequential() // to return a sequential LongStream. import java.util.*; import java.util.stream.LongStream; class GFG { // Driver code public static void main(String[] args) { // Creating an LongStream LongStream stream = LongStream.of(3L, 5L, 9L, 12L, 14L); // Using LongStream sequential() LongStream streamNew = stream.sequential(); // Displaying sequential LongStream streamNew.forEach(System.out::println); } } |
3 5 9 12 14
Example 2 :
// Java code for LongStream sequential() // to return a sequential LongStream. import java.util.*; import java.util.stream.LongStream; class GFG { // Driver code public static void main(String[] args) { // Creating an LongStream of elements // in range [-2, 4) LongStream stream = LongStream.range(-2L, 4L); // Using LongStream sequential() LongStream streamNew = stream.sequential(); // Displaying sequential IntStream streamNew.forEach(System.out::println); } } |
-2 -1 0 1 2 3
Recommended Posts:
- IntStream sequential() in Java
- DoubleStream sequential() in Java
- Creating Sequential Stream from an Iterator in Java
- LongStream of() in Java
- LongStream sum() in Java
- LongStream asDoubleStream() in Java
- LongStream skip() in Java
- LongStream min() in Java with examples
- LongStream max() in Java with examples
- LongStream sorted() in Java
- LongStream findFirst() in Java
- LongStream concat() in Java
- LongStream iterator() in Java
- LongStream summaryStatistics() in Java
- LongStream limit() 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 contribute@geeksforgeeks.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.


