Grokking Java Interview Questions
Vote

0% completed

​

map, flatMap, filter, and reduce

The operation filter() never changes an element, but it may reduce the number of elements. The operation map() does the opposite: it may replace every element, and it always keeps their number. Two other operations go further. flatMap() may change both the elements and their number, and reduce() replaces all of them with a single value.

Each question below adds one piece: nested data, the combination of values, streams of numbers without wrapper objects, and the tasks that a plain loop performs better.

What is the difference between map and flatMap?

Level: Junior

**`map()

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content