Reputation: 1
I have to write a method body of class Employee containing 3 objects and return an arraylist of employees whose attendance is greater than 70% using lambda expression.
Java
public List<Employee> findAttendance(List<Employee> emp) {
List<Employee> l = new ArrayList<Employee>();
l.forEach(emp -> (if(emp.getAttendance() >= 70)) {
l.add(emp);
});
}
Upvotes: 0
Views: 479
Reputation: 4460
List<Employee> empsWithGoodAttendance = l.stream()
.filter(e -> e.getAttendance() >= 70)
.collect(Collectors.toList());
Upvotes: 1