-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStream1.java
More file actions
23 lines (18 loc) · 848 Bytes
/
Copy pathStream1.java
File metadata and controls
23 lines (18 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.*;
import java.util.stream.*;
public class Stream1 {
public static void main(String[] args) {
List<Integer> number = Arrays.asList(2,3,4,5);
System.out.println(number);
List<Integer> square = number.stream().map(x -> x*x).collect(Collectors.toList());
System.out.println(square);
List<String> names = Arrays.asList("simon", "goes", "says", "did he?");
System.out.println(names);
List<String> result = names.stream().filter(x -> x.startsWith("s")).collect(Collectors.toList());
System.out.println(result);
List<String> order = names.stream().sorted().collect(Collectors.toList());
System.out.println(order);
Set<Integer> settest = number.stream().map(x -> x*x).collect(Collectors.toSet());
System.out.println(settest);
}
}