Skip to content
Advertisement

Java 8 List from String and List of String

I want to generate a list of strings, comprising id and external ids, from a list of Bean.

JavaScript

I got it using the below code, but here I need to do the stream twice.

JavaScript

Is there any better way to rewrite this code?

Advertisement

Answer

Use Stream.concat inside the flatMap operation:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement