forked from dameeta/JavaRepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumberParallel.java
More file actions
35 lines (23 loc) · 822 Bytes
/
NumberParallel.java
File metadata and controls
35 lines (23 loc) · 822 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
31
32
33
34
35
import java.util.ArrayList;
import java.util.List;
public class NumberParallel {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("without parallel...");
List<String> alphabet = getData();
alphabet.stream().forEach(System.out::println);
System.out.println("with Parallel stream...");
List<String> alpha2 = getData();
alpha2.parallelStream().forEach(System.out::println);
}
private static List<String> getData() {
List<String> alphabet = new ArrayList<>();
int n = 97; // 97 = a , 122 = z
while (n <= 122) {
char c = (char) n;
alphabet.add(String.valueOf(c));
n++;
}
return alphabet;
}
}