What is the difference between `map()` and `flatMap()`?

  1. map flattens, flatMap transforms
  2. map transforms, flatMap flattens nested streams
  3. Both do the same
  4. flatMap does not exist
Correct answer map transforms, flatMap flattens nested streams

Explanation

`map()` transforms elements; `flatMap()` flattens nested structures into a single stream.

Update: Admin added a tag on this question

Topics

By Admin · · 43 views