09 January 2007

Don’t Initialize Variables Twice

Java by default initializes variables to a known value upon
calling the particular class’s constructor. All objects are set to
null, integers (byte, short, int, long) are set to 0, float and double
are set to 0.0, and Booleans are set to false.
This is especially
important if the class has been extended from another
class, as all chain constructors are automatically called when
creating an object with the new keyword.

Reference: James McGovern

No comments: