IntStream sequential() returns a sequential IntStream. It may return itself, either because the stream was already sequential, or because the underlying stream state was modified to be sequential. IntStream 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 :
IntStream sequential() Where, IntStream is a sequence of primitive int-valued element.
Example 1 :
// Java code for IntStream sequential() // to return a sequential IntStream. import java.util.*; import java.util.stream.IntStream; class GFG { // Driver code public static void main(String[] args) { // Creating an IntStream IntStream stream = IntStream.of(3, 5, 9, 12, 14); // Using IntStream sequential() IntStream streamNew = stream.sequential(); // Displaying sequential IntStream streamNew.forEach(System.out::println); } } |
3 5 9 12 14
Example 2 :
// Java code for IntStream sequential() // to return a sequential IntStream. import java.util.*; import java.util.stream.IntStream; class GFG { // Driver code public static void main(String[] args) { // Creating an IntStream of elements // in range [-2, 4) IntStream stream = IntStream.range(-2, 4); // Using IntStream sequential() IntStream streamNew = stream.sequential(); // Displaying sequential IntStream streamNew.forEach(System.out::println); } } |
-2 -1 0 1 2 3
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.
Recommended Posts:
- DoubleStream sequential() in Java
- LongStream sequential() in Java
- Creating Sequential Stream from an Iterator in Java
- java.util.stream.IntStream/LongStream | Search an element
- IntStream iterator() in Java
- IntStream rangeClosed() in Java
- IntStream map(IntUnaryOperator mapper) in Java
- IntStream findFirst() in Java
- IntStream parallel() in Java
- IntStream empty() in Java with examples
- IntStream distinct() in Java with examples
- IntStream peek() in Java with examples
- IntStream average() in Java with Examples
- IntStream max() in Java with examples
- IntStream min() in Java with Examples
- IntStream count() in Java with examples
- IntStream skip() in Java
- IntStream filter() in Java with examples
- IntStream concat() in Java
- IntStream anyMatch() in Java with examples
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.

