A is special method of the class that will be automatically invoked when an instance of the class is created is called as constructor.
Constructors are mainly used to initialize private fields of the class while creating an instance for the class.
When you are not creating a constructor in the class, then compiler will automatically create a default constructor in the class that initializes all numeric fields in the class to zero and all string and object fields to null.
Syntax.
[Access Modifier] ClassName([Parameters])
{
}
Constructors are mainly used to initialize private fields of the class while creating an instance for the class.
When you are not creating a constructor in the class, then compiler will automatically create a default constructor in the class that initializes all numeric fields in the class to zero and all string and object fields to null.
Syntax.
[Access Modifier] ClassName([Parameters])
{
}