IntStream forEachOrdered(IntConsumer action)
performs
an action for each element of this stream in encounter order.
This is a terminal operation.
forEachOrdered
has the following syntax.
void forEachOrdered(IntConsumer action)
The following example shows how to use forEachOrdered
.
import java.util.stream.IntStream; 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.