Just wanted to see if I can shorten the code to add a new ArrayList to a HashMap. This is what I currently have:
public void putStudent(Student newStudent) { ArrayList<Student> studentToAdd = new ArrayList<Student>(); studentToAdd.add(newStudent); mySchools.put(newStudent.getName(), studentToAdd); }
mySchool is a HashMap<String, ArrayList<Student>>. What I currently have works but I wanted to see if there's a more efficient way to accomplish this. Any ideas will be appreciated.