map transforms data; flatMap transforms and flattens data streams.
The map function is used to transform each item in a stream into another item, maintaining a one-to-one mapping. In contrast, flatMap is used when each item can be transformed into a stream of items, which are then flattened into a single stream. For example, map can convert a stream of item IDs into their names, while flatMap could convert each item ID into a stream of related reviews.
Additional Notes
How does map differ from flatMap in Project Reactor?