Java Constructor

When the Objects are created, it is necessary to initialize it with initial value. Java supports a special type of method, called constructor that initializes the object automatically when the object is created. The constructor has some characteristics, some of them are listed below:

  1. Constructor has the same name as the class name.
  2. Constructors do not have any return type.
  3. Constructors are called automatically when an object is created.
  4. Constructors are always public.
  5. Constructor can be overloaded like function overloading.