July 6, 2014
Constructors in Java
Basically, a class constructor is a special method used to create an object of a class, and initialize its instance variable. A class can define multiple constructors with different sets of method parameters.
Remember : A constructor must match the name of the class and cannot declare a return value (not even void).
Here are the rules to define constructors :
- The name of the constructor must match with the name of the java class;
- The constructor doesn’t have a return type (not even void).
One Comment
Very good article, pay attention to you.