IntStream sequential() in Java
Last Updated :
06 Dec, 2018
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 :
import java.util.*;
import java.util.stream.IntStream;
class GFG {
public static void main(String[] args)
{
IntStream stream = IntStream.of( 3 , 5 , 9 , 12 , 14 );
IntStream streamNew = stream.sequential();
streamNew.forEach(System.out::println);
}
}
|
Example 2 :
import java.util.*;
import java.util.stream.IntStream;
class GFG {
public static void main(String[] args)
{
IntStream stream = IntStream.range(- 2 , 4 );
IntStream streamNew = stream.sequential();
streamNew.forEach(System.out::println);
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...