Initializing Objects with Constructors
When an object of a class is created, its instance variables are initialized by default.
Each class can provide a constructor that initializes an object of a class when the object is created.
Java requires a constructor call for every object that is created.
Keyword new requests memory from the system to store an object, then calls the corresponding class’s constructor to initialize the object.
A constructor must have the same name as the class.
By default, the compiler provides a default constructor with no parameters in any class that does not explicitly include a constructor.
Instance variables are initialized to their default values.
Can provide your own constructor to specify custom initialization for objects of your class.
A constructor’s parameter list specifies the data it requires to perform its task.
Constructors cannot return values, so they cannot specify a return type.
Normally, constructors are declared public.
If you declare any constructors for a class, the Java compiler will not create a default constructor for that class.