February 2014
Beginner
1248 pages
62h 25m
English
Do not call overridable methods from constructors. When creating a subclass object, this could lead to an overridden method being called before the subclass object is fully initialized.
Recall that when you construct a subclass object, its constructor first calls one of the direct superclass’s constructors. If the superclass constructor calls an overridable method, the subclass’s version of that method will be called by the superclass constructor—before the sub-class constructor’s body has a chance to execute. This could lead to subtle, difficult-to-detect errors if the subclass method that was called depends on initialization that has not yet been performed in the
Read now
Unlock full access