What are you trying to iterate? Are you trying to iterate the values set of that Map? I presume you already know how to get the values from the Map as a Collection view.Since all Collections have a stream() method, you can use that to get a Stream from that Collection:-Now, to convert that to a Stream<String> rather than a Stream of Lists, you will need to flatten it, and that flattening method needs a Function to convert the elements to something which can be flattened, probably another Stream. You can probably do that with a method reference, since all you are doing is calling the stream() method on each List.Now let's print that. There are all sorts of options; I shall go for a Collector. How about the Collector which uses a StringJoiner behind the scenes? Method link.Now put the whole lot together into one statement:-I think that will work; I am not quite sure about the flatMap line.
Depending on which book you have read, you may consider my indentation correct or incorrect.
posted 1 year ago
A few minutes ago, I wrote:. . . I think that will work. . . .