IntStream forEachOrdered(IntConsumer action) example
Description
IntStream forEachOrdered(IntConsumer action)
performs
an action for each element of this stream in encounter order.
This is a terminal operation.
Syntax
forEachOrdered
has the following syntax.
void forEachOrdered(IntConsumer action)
Example
The following example shows how to use forEachOrdered
.
import java.util.stream.IntStream;
//from w ww. jav a 2 s .co m
public class Main {
public static void main(String[] args) {
IntStream i = IntStream.of(1,2,3,4);
i.forEachOrdered(System.out::println);
}
}
The code above generates the following result.