Say I have a list of objects called Student. Object Student is defined like so
public Class Student {
private String studentName;
private String courseTaking;
}
In the list of students, there can be multiple student objects with the same studentName but different courseTaking. Now I want to turn the list of students into a map of studentName and courseTaking like so
Map<String, Set<String>>
The key is studentName, and the value is all of the courseTaking of the same student put together as a set. How can I do this using stream() & collect()?