forked from davidjava1991/java17CompleteCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample2.java
More file actions
23 lines (21 loc) · 707 Bytes
/
Copy pathExample2.java
File metadata and controls
23 lines (21 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.david.class144;
import java.util.ArrayList;
public class Example2 {
public static void main(String[] args) {
ArrayList<Student> list= new ArrayList<>();
list.add(new Student(32, "Paul", 42));
list.add(new Student(3, "David", 22));
list.add(new Student(42, "Phil", 32));
list.add(new Student(12, "jose", 23));
list.add(new Student(7, "sam", 26));
list.add(new Student(67, "Adam", 41));
list.stream()
.filter(p-> p.age >25)
.map(p-> "age = "+p.age)
.forEach(System.out::println);
System.out.println("All match : "+list.stream()
.allMatch(s -> s.id>2));
System.out.println("Any match : "+list.stream()
.anyMatch(s -> s.id>20));
}
}