0 votes
in JAVA by (30.8k points)
What does the flatmap() function do? why you need it?

1 Answer

0 votes
by (30.8k points)
The flatmap function is an extension of the map function. Apart from transforming one object into another, it can also flatten it.

For example, if you have a list of the list but you want to combine all elements of lists into just one list. In this case, you can use flatMap() for flattening. At the same time, you can also transform an object like you do use map() function.

Related questions