2.8 Constructors
Introduction
A constructor is a special method that runs automatically when an object is created with `new`, responsible for initializing its instance variables. A constructor shares its name with the class, has no return type (not even `void`), and can be overloaded to support multiple ways of creating an object.
Key Concepts
Java Syntax
Code Examples
The constructor receives `name` and `grade` as arguments and assigns them to the object's fields using `this` to disambiguate from the parameter names.