IntStream forEachOrdered() method in Java Last Updated : 06 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report IntStream forEachOrdered(IntConsumer action) performs an action for each element of this stream in encounter order. IntStream forEachOrdered(IntConsumer action) is a terminal operation i.e, it may traverse the stream to produce a result or a side-effect. Syntax : void forEachOrdered(IntConsumer action) Parameter : IntConsumer represents an operation that accepts a single int-valued argument and returns no result. This is the primitive type specialization of Consumer for int. Note : forEachOrdered(IntConsumer action) performs an action for each element of this stream, in the encounter order of the stream if the stream has a defined encounter order. Example 1 : Java // Java code for IntStream forEachOrdered // (IntConsumer action) in Java 8 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(2, 3, 4, 5); // Using IntStream.forEachOrdered stream.forEachOrdered(System.out::println); } } Output: 2 3 4 5 Example 2 : Java // Java code for IntStream forEachOrdered // (IntConsumer action) in Java 8 import java.util.*; import java.util.stream.IntStream; class GFG { // Driver code public static void main(String[] args) { // Creating an IntStream IntStream stream = IntStream.range(5, 11); // Using IntStream.forEachOrdered() on // sequential stream stream.forEachOrdered(System.out::println); } } Output: 5 6 7 8 9 10 Example 3 : Java // Java code for IntStream forEachOrdered // (IntConsumer action) in Java 8 import java.util.*; import java.util.stream.IntStream; class GFG { // Driver code public static void main(String[] args) { // Creating an IntStream IntStream stream = IntStream.range(5, 11); // Using IntStream.forEachOrdered() on // parallel stream stream.parallel().forEachOrdered(System.out::println); } } Output : 5 6 7 8 9 10 Comment More infoAdvertise with us Next Article IntStream forEachOrdered() method in Java S Sahil_Bansall Follow Improve Article Tags : Misc Java Java - util package Java-Functions java-stream java-intstream +2 More Practice Tags : JavaMisc Similar Reads IntStream forEach() method in Java The IntStream forEach() method in Java is a terminal operation that performs a given action on each element of the stream. It is commonly used to iterate through primitive int values in a functional style introduced in Java 8.Syntax of IntStream forEach() Methodvoid forEach(IntConsumer action)Parame 2 min read Iterable forEach() Method in Java In Java, the foreach() method is the default method in the Iterable interface. It provides a simple way to iterate over all elements of an Iterable such as List, Set, etc. using a lambda expression or method reference. Example 1: This example demonstrates iterating over a List using an Iterator to p 3 min read Stream forEachOrdered() method in Java with examples Stream forEachOrdered(Consumer action) performs an action for each element of this stream, in the encounter order of the stream if the stream has a defined encounter order. Stream forEachOrdered(Consumer action) is a terminal operation i.e, it may traverse the stream to produce a result or a side-ef 2 min read Vector forEach() method in Java The forEach() method of Vector is used to perform a given action for every element of the Iterable of Vector until all elements have been Processed by the method or an exception occurs. The operations are performed in the order of iteration if the order is specified by the method. Exceptions thrown 3 min read IntStream of() in Java IntStream of(int t) IntStream of(int t) returns a sequential IntStream containing a single element. Syntax : static IntStream of(int t) Parameters : IntStream : A sequence of primitive int-valued elements.t : Represents the single element in the IntStream. Return Value : IntStream of(int t) returns 4 min read Like