In this video, start off with a list of employee data and learn how to transform it into a map that contains all the different job titles as keys, and the average salary of each of those job titles as the corresponding values.
(upbeat music) … - [Instructor] Okay, so let's take a look … at how I went about converting this list of employees … into a map that contains all the different job titles … as well as the associated average salary for that job title. … So, first of all, I knew that the answer here … should be a map where the key is a string, … and the corresponding value for each key is a float. … Which is going to be the average salary … for each group of employees. … And of course we need to import map … and I called this average salaries map, okay? … And what I did next, was I said employees … and converted that to a stream, okay? … And then I said, dot collect, … and I used the collectors.groupingby collector … to group all of the employees by their job title. … So what I did for that function that I passed to it, … 'cause I said employee … and simply returned employee.jobtitle, okay? … And just ignore these red squiggly lines for now … it's going to keep doing that until I get to the very end. … So at this point what we have is a map …
Skill Level Advanced
Java Design Patterns: Structuralwith Bethan Palmer1h 38m Intermediate
1. Introduction to Functional Programming
2. First-Class Functions
3. Working with Streams in Java
4. Advanced Concepts
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.