IntStream forEach(IntConsumer action)
performs an action for each element of this stream. This is a terminal operation.
forEach
has the following syntax.
void forEach(IntConsumer action)
The following example shows how to use forEach
.
import java.util.stream.IntStream; public class Main { public static void main(String[] args) { IntStream i = IntStream.of(1); i.forEach(System.out::println); } }
The code above generates the following result.