From the course: Functional Programming with Java
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Challenge: Average salary calculator - Java Tutorial
From the course: Functional Programming with Java
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Map in Java8m 4s
-
(Locked)
Filter in Java10m 30s
-
(Locked)
Reduce in Java7m 46s
-
(Locked)
Collect in Java8m 8s
-
(Locked)
Challenge: Stream exercises1m 24s
-
(Locked)
Solution: Stream exercises3m 59s
-
(Locked)
Combine list functions4m 47s
-
(Locked)
Parallel streams5m 26s
-
(Locked)
Challenge: Average salary calculator2m 57s
-
(Locked)
Solution: Average salary calculator4m 10s
-
(Locked)
-