Constructors with parameters force callers to provide data when creating an object. This prevents incomplete initialization:
class Student {
String name;
int grade;
Student(String name, int grade) {
this.name = name;
this.grade = grade;
}
}
Now new Student() is a compile error. The only way to create a Student is new Student("Alice", 10). This guarantees every student has a name and grade from the moment it exists.
If some fields are optional, you can provide multiple constructors with different parameter lists. That leads to the next topic: constructor overloading.