forked from janbodnar/Java-Advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForEachConsSpec.java
More file actions
30 lines (21 loc) · 816 Bytes
/
ForEachConsSpec.java
File metadata and controls
30 lines (21 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.zetcode;
import java.util.Arrays;
import java.util.function.DoubleConsumer;
import java.util.function.IntConsumer;
import java.util.function.LongConsumer;
public class ForEachConsSpec {
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);
System.out.println();
long[] lnums = { 13L, 3L, 6L, 1L, 8L };
LongConsumer lcons = l -> System.out.print(l + " ");
Arrays.stream(lnums).forEach(lcons);
System.out.println();
double[] dnums = { 3.4d, 9d, 6.8d, 10.3d, 2.3d };
DoubleConsumer dcons = d -> System.out.print(d + " ");
Arrays.stream(dnums).forEach(dcons);
System.out.println();
}
}