I'm reading a Java 8 book by Ricahrd Warburton and he provided the following excercise:
try rewriting the following using method references:
[...]
The flatMap approach to concatenate lists
I really don't understand how to apply flatMap here. The thing that confused me was that flat map is used to map each element of a Stream to another Stream and then concatenate them together to produce a larger Stream but here we have to separate List<T>.
public static <T> List<T> concat(List<T> lst1, List<T> lst2){
//lst1.stream().flatMap() - it maps each elements
//of lst1 to stream and concatenates it for each
//element
}
Any ideas?