-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathAllMatchExample.java
More file actions
31 lines (25 loc) · 924 Bytes
/
AllMatchExample.java
File metadata and controls
31 lines (25 loc) · 924 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
package StreamAllMatch;
import java.util.Arrays;
import java.util.List;
public class AllMatchExample {
public static void main(String[] args) {
List<Employee> employees = Arrays.asList(
new Employee(1, 55000.0),
new Employee(2, 75000.0),
new Employee(3, 80000.0),
new Employee(4, 60000.0),
new Employee(5, 90000.0)
);
double salaryThreshold = 50000.0;
boolean allEmployeesAboveThreshold = employees.stream()
.allMatch(employee ->
employee.getSalary() > salaryThreshold);
if (allEmployeesAboveThreshold) {
System.out.println
("All employees have salaries above the threshold.");
} else {
System.out.println
("Not all employees have salaries above the threshold.");
}
}
}