Skip to content
Sharp

Reactive Streams · interview question

When using Project Reactor, how does the 'map' operator differ from 'flatMap'?

Multiple choiceMediumchapter-19-curatedpremiumreactive-streamsnon-blocking-i-o-event-loops
java
Flux.just(1, 2, 3).map(i -> i * 2).subscribe(System.out::println);
Choose one answer
Answer and explanation

Correct answer

C. Map transforms data items individually, flatMap combines multiple streams.

Why

The 'map' operator applies a transformation to each item in a stream individually, while 'flatMap' can be used to flatten multiple streams into a single stream.

Test yourself on Reactive Streams

A free test with instant, explained results. No account needed.

Start free test
All Reactive Streams questions →