Problems
Use the following problems to test your programming prowess in functional-style programming in Java. I strongly encourage you to give each problem a try before you turn to the solutions and download the example programs:
- 178. Working with mapMulti(): Explain and exemplify the JDK 16,
mapMulti()
. Provide a brief introduction, explain how it works in comparison withflatMap()
, and point out whenmapMulti()
is a good fit. - 179. Streaming custom code to map: Imagine a class that shapes some blog posts. Each post is identified by a unique integer id and it has several properties including its tags. The tags of each post are actually represented as a string of tags separated by hashtag (
#
). Whenever we need the list of tags for a given post, we can call theallTags()
helper method. Our goal is to write a stream pipeline that extracts from this list of tags aMap<String, List<Integer>>
containing for each tag (key) the list of posts (value). - 180. Exemplifying method reference...