Creating an Object
A constructor is a block of code that has the same name as the class and tells the computer how to create a new object.
Painter alice = new Painter();
- Painter() calls the constructor in the Painter class to create the Painter class.
When a constructor is called, Java looks for the constructor in the class and executes the code inside the constructor before moving on to the next statement.

The empty parentheses after the name of the class means that the constructor has no parameters. This is a no-argument constructor, which is a constructor with no parameters.

Components of a Constructor
To write a constructor, we first write the access modifier public. The constructor should be public so it can be accessed from outside of the class.
Next, we write the name of the class. A constructor should have the same name as the class.
Then, we write empty parentheses since there are no parameters.

The first line of the constructor is the constructor signature. The constructor signature is the first line of the constructor which includes the public keyword, the constructor name, and any parameters.

Inside the curly braces ({}), we write the body of the constructors by assigning values to the instance variables.

A no-argument constructor often assigns default values to the instance variables. A default value is a predefined value that is used by a program when the user does not provide a value.

If we don’t write a no-argument constructor in a class, Java will automatically provide one. The instance variable will be assigned default values based on the data type.