What is a constructor?
A constructor is a "kind of" method in java which is used to initialize objects. The constructor is called when an object of a class is created. It can be used to set initial values for object attributes. A constructor definition is similar to a method definition, except that the constructor should have same name as the class and doesn't contain a return type.
public class MyClass {
public MyClass() {
// class level definitions
}
}