I have a AssistantList and need to map to Map of (Key - Assistant Login, Value - ArrayList of its Supervisor)
I used below code to map using for loop.
How can I use stream api to achieve the same functionality,
for(Assistant assistant: assistantList)
{
for(Supervisor supervisor: assistant.getSupervisorList())
{
map.computeIfAbsent(assistant.getLogin(), k->new ArrayList<>()).add(supervisor.getLogin());
}
}
Thank you