I wrote a constructors that can passes all the fields, including an Arraylist. I don't know what to do if I want constructors where I'm not passing the Arraylist and instead give it an empty Arraylist.
For example I already wrote a Course class and now I'm writing a Student class. The student class contains an Arraylist.
class Student {
String studentFirstName;
String studentLastName;
ArrayList<Course> studentSchedule = new ArrayList<Course>();
// Constructors
Student(String newFirstName, String newLastName) {
this.Student(newFirstName, newLastName, _______ ); //what to put in the blank?
}
Student(String newFirstName, String newLastName, ArrayList<Course> newSchedule) {
this.studentFirstName = newFirstName;
this.studentLastName = newLastName;
this.studentSchedule = newSchedule;
}
.
.
.
I'm stuck here. Putting null in the blank does not work, I get compiler warning: The method Student(String, String, null) is undefined for the type Student Obviously I'm missing the point.
How do I get the constructor to give me an empty Arraylist?