Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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

FlatMap + Collector Example In Java 8 - List Of Object And Stream Example
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. 


This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here

Share the post

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

×

Subscribe to Javarevisited: Blog About Java Programmin

Get updates delivered right to your inbox!

Thank you for your subscription

×