A constructor in Java does not actually βbuildβ an object; it is used to initialize fields.
Imagine that your abstract class has fields x and y and that you always want them to be initialized in a certain way, no matter what specific concrete subclass will ultimately be created. Thus, you create a constructor and initialize these fields.
Now, if you have two different subclasses of your abstract class, when you create them, their calls will be called, and then the parent constructor will be called and the fields will be initialized.
If you do nothing, the default constructor of the parent will be called. However, you can use the super keyword to invoke the specific constructor of the parent class.
Uri Jan 31 '10 at 4:02 2010-01-31 04:02
source share