- There is no return type given in a constructor signature (header). The value is this object itself so there is no need to indicate a return value.
- There is no return statement in the body of the constructor.
- The first line of a constructor must either be a call on another constructor in the same class (using
this
), or a call on the superclass constructor (usingsuper
). If the first line is neither of these, the compiler automatically inserts a call to the parameterless super class constructor.
A java blog with a collection of examples and tutorials on Java and related technologies. (Under maintenance with continuous updates) Be in touch with java jazzle or k2java.blogspot.com.
Monday, May 16, 2011
Differences between methods and constructors.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment