220: Highlights
Constructors perform computations, such as instance-variable assignment, that you want to occur when your program creates an instance.
Each constructor is named for the class in which it is defined. All constructors return class instances.
In the absence of any constructors defined by you, Java creates a default constructor, which has no parameters.
If
you want to define a zero-parameter constructor to displace the default constructor,
then
instantiate the following pattern:
public
class name
() { ... }
If
you want to define a constructor with parameters,
then
instantiate the following pattern:
public
class name
(
parameter specifications
) { ... }
When you create instances, the number and types of the arguments that you supply determine which constructor is called.