Create a default constructor, like
Student();
In Java, a default constructor refers to a nullary constructor that is automatically generated by the compiler if no constructors have been defined for the class. The default constructor implicitly calls the superclass's nullary constructor, then executes an empty body. Also, you can write it by your own self.
Note that, there can be many constructors according to your coding design and requirement. Say,
class Student {
// default constructor
public Student() {}
// one param constructor
public Student(int id) {
this.id = id;
}
// two param constructor
public Student(int id, String name) {
this.id = id;
this.name = name;
}
}
If you have the default constructor, then without
Student std = new Student(1, "Benjamin");
you can create a std object like:
Student std = new Student();