I have Answer entity which has values like this
question answer
1 x
2 y
3 z
4 p
1 x
2 q
3 r
I need to get answers group by questions
Map<Integer, List<String>>
<1, [x,x]
2, [y,p]
3, [z,r]
4, [p]>
I could get List<Answer> like this
Map<Integer, List<Answer>> collect = answers
.stream()
.collect(Collectors.groupingBy(Answer::getQuestion));
but I can't find a way to get it as List<String> rather than List<Answer>?