-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyStreamLoopMain.java
More file actions
47 lines (36 loc) · 1.3 KB
/
Copy pathMyStreamLoopMain.java
File metadata and controls
47 lines (36 loc) · 1.3 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
37
38
39
40
41
42
43
44
45
46
47
package lambda.lambda5.mystream;
import java.util.List;
public class MyStreamLoopMain {
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> result = MyStreamV3.of(students)
.filter(n -> n.getScore() >= 80)
.map(s -> s.getName())
.toList();
// 외부 반복
for (String s : result) {
System.out.println("name : " + s);
}
MyStreamV3.of(students)
.filter(n -> n.getScore() >= 80)
.map(s -> s.getName().toUpperCase())
.forEach(s-> System.out.println("name : " + s));
}
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();
}
}