11.Find the average salary of each department using stream APIs | Java coding interview questions

preview_player
Показать описание
In this video, we solved below problem statement using Java stream APIs

Problem statement - Find the average salary of each department using java8 stream APIs

Employee class -
name;
department;
salary;

new Employee("Alice", "HR", 50000),
new Employee("Bob", "IT", 60000),
new Employee("Charlie", "HR", 70000),
new Employee("David", "IT", 75000),
new Employee("Eve", "Finance", 80000),
new Employee("Frank", "Finance", 85000));

Output -
Department: Finance, Average Salary: 82500.0
Department: HR, Average Salary: 60000.0
Department: IT, Average Salary: 67500.0

For Complete Java Interview Preparation Watch this Playlist:

For complete list of stream apis coding interview questions:

Рекомендации по теме