I have a list of Objects that I want to map to another list that is joined by another object of that type.
i.e:
List<Integer> list = List.of(5,6,7,8);
// is it possible to insert `1` between every item in the list?
// joined list = [5,1,6,1,7,1,8]
This is just an example, the list can be of any type not just Integer.
My use case is this: I have a list of objects of type X, and I need to insert a certain object between every 2 items of that list.
I know it can be easily done by a for-loop, but wondering if there's a solution using Stream.