Java Stream API Exercises
Java Stream API Exercises
// constructor, getters
}
List<Employee> employees = Arrays.asList(
new Employee("Alice", "HR", 30000, 25),
new Employee("Bob", "IT", 50000, 30),
new Employee("Carol", "HR", 35000, 28),
new Employee("David", "IT", 60000, 35),
new Employee("Eve", "Sales", 40000, 29)
);
```
✍️ Tasks:
1. Print names of employees in IT department.
2. Get average salary of employees using `Collectors.averagingDouble()`.
3. Get list of employees with salary > 40000.
4. Group employees by department.
5. Find employee with highest salary.
6. Count employees per department.