a constructor is a special method. It is used to give objects characteristics ASAP.
examplE
Theory
SYNTAX: modifier + className + () + { + }
TWO TYPES:
constructor is a special method, therefore you can choose between non-parametrised and parametrised constructors as you did with methods.
- Constructor with parameter
- Constructor without parameter
FACTS
- constructor never returns any value
- constructor has the same name as the class
- you can have multiple constructors in one class