Filtering is when you take a list of items and create another list that contains only a subset of the original list. Learn how the Java Filter function allows you to functionally filter a list.
- [Instructor] The next important stream function … we're going to look at here is called filter. … Filter is used when you want to find all the elements … in an array or list that fit some kind of criteria. … So for example, if we have a list of numbers … and we want to get all the numbers from it that are even, … or if we have a list of employee objects, … and we want to find the employees from this list … that make more than a certain amount per year. … These are some examples of things … that the filter function can help us with. … So the syntax of filter is similar to map. … We convert our list data into a stream, … and then we can call the filter function … with a function object as an argument. … The main difference between filter and map … is the type of function that we pass to it. … You see, with map, … we pass in a function that returns a value … for each element in our stream. … And the return value of this function represents … what that element becomes after the element is processed. …
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.