-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyStreamV3Main.java
More file actions
36 lines (28 loc) · 1.01 KB
/
Copy pathMyStreamV3Main.java
File metadata and controls
36 lines (28 loc) · 1.01 KB
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
36
package lambda.lambda5.mystream;
import java.util.List;
public class MyStreamV3Main {
public static void main(String[] args) {
List<Student> students = List.of(
new Student("Apple", 100),
new Student("Banana", 80),
new Student("Berry", 50),
new Student("Tomato", 40)
);
List<String> result1 = ex1(students);
System.out.println("result = " + result1);
List<String> result2 = ex2(students);
System.out.println("result2 = " + result2);
}
private static List<String> ex2(List<Student> students) {
return MyStreamV3.of(students)
.filter(n -> n.getScore() >= 80)
.map(s -> s.getName().toUpperCase())
.toList();
}
private static List<String> ex1(List<Student> students) {
return MyStreamV3.of(students)
.filter(student -> student.getScore() >= 80)
.map( s-> s.getName())
.toList();
}
}