A constructor is used to initialize objects in Java. It is called when an object of a class, using the new() keyword, is created and can be used to set initial values to the data members of that same class.
Read moreWhat are constructors with example?
Constructors have the same name as the class or struct, and they usually initialize the data members of the new object . In the following example, a class named Taxi is defined by using a simple constructor. This class is then instantiated with the new operator.
Read more