In this video we look at the intermediate operations: map, flatMap and sorted. Intermediate operations produce a Stream as a result. Firstly, map() is used to transform a stream of Strings into a stream of their lengths. Next, flatMap() is used to flatten a stream of lists of Strings to a stream of Strings. Lastly, sorted() with an optional Comparator is explained with code. At the end, a complete pipeline example is presented which demonstrates the stateful nature of sorted().
The full Streams playlist is here: • Playlist
0:00 map()
1:00 flatMap()
1:53 sorted()
3:01 sorted() pipeline example