I have something like below:
public class MyClass { private Long stackId private Long questionId }
A collection, say 100, where the stack can be duplicated with different questionIds. Its one-to-many relationship between stackId and questionId
Is there a way streamy , java 8 to convert to the following strcuture:
public class MyOtherClass { private Long stackId private Collection<Long> questionIds }
What will be a set of 25, with each instance having a nested set of 4 questionIds.
Entrance:
[{1,100},{1,101},{1,102},{1,103},{2,200},{2,201},{2,202},{1,203}]
Output
[{1, [100,101,102,103]},{2,[200,201,202,203]}]