Constructor

Constructor

  • A special method used to initialize objects
  • The constructor has the same name as the class
  • It does not have a return type, not even void
  • It can be overloaded to accept different parameters
  • Type
    • Default Constructor
      • Automatically provided by Java if no other constructors are defined
      • It initializes object with default values
    • Parameterized Constructor
      • It initializes object with specific values through parameters