-
Notifications
You must be signed in to change notification settings - Fork 4
Java 8 IntConsumer Example
Ramesh Fadatare edited this page Jul 14, 2019
·
2 revisions
In this example, we create the IntConsumer interface and iterate over them with forEach().
import java.util.Arrays;
import java.util.function.IntConsumer;
public class JavaForEachConsSpec {
public static void main(String[] args) {
int[] inums = { 3, 5, 6, 7, 5 };
IntConsumer icons = i -> System.out.print(i + " ");
Arrays.stream(inums).forEach(icons);
}
}
Output:
3 5 6 7 5