From the course: Functional Programming with Java

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Challenge: Average salary calculator

Challenge: Average salary calculator - Java Tutorial

From the course: Functional Programming with Java

Start my 1-month free trial

Challenge: Average salary calculator

(bouncy music) - [Instructor] A few minutes ago, we saw an example of how stream functions can be chained together to perform a wide variety of computations. In this example, we combined the map filter and reduce functions to find the average salary of all the developers in a list of employee objects and see how it compared to the average salary of all the non-developer employees. So the challenge that I'm going to give you in this video takes that example and runs with it a little bit. Remember that in our previous example, in order to compare the average developer salary and the average non-developer salary, we had to perform all the calculations twice, once for the developers and once for the non-developers. However, this could be improved, and here's how. Instead of just duplicating the operations twice and assigning those results to individual variables, what if we instead used the functions we've learned about to create a map object whose keys are all the different job titles of…

Contents