- GETTING STARTED
- BASIC JAVA
- JAVA STRINGS
- EXCEPTION HANDLING
- JAVA 9
- EFFECTIVE JAVA
A class contains constructors that are invoked to create objects from the class blueprint. Constructors have one purpose in life: to create an instance of a class. This can also be called creating an object.
Constructor in java is a special type of method that is used to initialize the object. Constructor is invoked at the time of object creation. It constructs the values i.e. provides data for the object that is why it is known as constructor. Typically the constructor initializes the fields of the object that need initialization. Constructors also takes parameters, so fields can be initialized in the object at creation time.
Defintiion: Constructor is a special type of method that is used to initialize the object.
Constructors is covered in more detail in OOP section.