What is the difference between stream’s map and flatMap?

Map in streams API’s are basically used to convert one type to other and it return non-flat stream object.
For example Stream of String is transformed into a Stream of Integer.
When applied against the array, list, set etc. it return the object of the relevent data set applied to it, confused…?
Let see an example

Streams Interview Question

50% LikesVS
50% Dislikes

Leave a Reply

Your email address will not be published. Required fields are marked *