Reducing is when you take a list of items and process all the values down to a single value, such as getting the sum of a list of numbers. Learn how the Java Reduce function allows you to reduce a list of items down to a single value.
- [Instructor] The next important list processing operation … that we're going to learn about … is something called reducing. … And to do it, we're going to use yet another … of Java's built in functions called reduce. … Now the purpose of reducing might not be quite as apparent … as mapping or filtering, … so let's take a look at how it works. … What reducing allows us to do is take a list of data … and well, reduce it down to a single piece of data. … So we just reduce if we wanted to take a list of numbers … and reduce it down to a sum or an average, for example. … What reduce does essentially is it starts off … with an initial value, say zero … if we're working with integers, … and for each element in the stream, … it modifies this initial value in some way … until after we've processed all our elements, … we end up with the result. … So in the case of finding the sum of a list of numbers, … for example, we'd start off with zero … and then we'd add each element to the initial value. …
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.