FlatMap + Collector Example in Java 8 - List of Object and Stream Example

yotube
0
I was searching for a good example of FlatMap but didn't found a good one, so created my own. As name suggest FlatMap is used to flatten stream like unwinding multiple list of values. For example you have a Stream of List of Integer and you want to create Stream of Integer by unwinding those list, you can do that using FlatMap function from java.util.Stream class. Coming back to FlatMap, its actually a general concept which is available in other functional programming language like Scala. Just like map() function works by applying a function to each element in the Stream, FlatMap works by applying a function that returns a sequence for each element in the list, and flattening the results into Stream or another list. 

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top