Constructor in Java
→ Constructor is a special type of method also contains collection of statements that is used to initialize objects. When an object of a class is created. It can be used to set initial values for object attributes:.
Rules for creating constructor
Types of Java constructors
→ There are two types of constructors in Java:
1) Default Constructor in java
If you don't define a constructor in a class, then compiler automatic creates a Default Constructor for the class, it is also known as no arguments.
2) Parameterized Constructor in java
→ Constructor that have parameters is known as parameterized constructor.
Constructor Overloading in Java
Constructor overloading is a technique, more than one constructor with different parameter list, and each constructor performs a different task .
Next TopicStatic Keyword in Java