Section Lists to Map
Write a method called
sectionListsToMap that, given a
Strings, parses it into a
Map<String, Set<String>> as follows.
String in the passed list contains a comma-separated list of names of people in a discussion section.
The first name is the section leader, and the rest are students.
Your map should map each section leader to the set of students in their section.
No section leader or student will appear twice in the data set.
For example, given the
Strings "challen,student1", "ruisong4,student2, student3" and "friendly,student4, student5",
your map would have keys "challen", "ruisong4", and "friendly".
"challen" would map to a set containing "student1", "ruisong4" would map to a set containing "student2" and
"student3", and so on.
You should assert that the passed
String is not
null, but if it is not
null it will have the format
A few hints for approaching this problem.
First, consider how to use
.trim appropriately to parse the input
You should get this part to work before proceeding.
Then consider when you need to create the map and each set, and how to populate them.
java.util.HashSet are already provided
You should not need additional
import statements to complete this problem.