Hi everyone,
While studying with the excellent and very helpful
Java 17 Study Guide I noticed a few potential errors. I'll make a separate post for each one so I can add all the relevant information without it getting too confusing, so here is the first one:
On page 300 in the section
Initializing Instances
, the fifth rule of
Initialize Instance of X
is specified as:
5. Initialize the constructor, including any overloaded constructors referenced with this().
See:
Initialize Instance of X
1. Initialize class X if it has not been previously initialized.
2. If there is a superclass Y of X, then initialize the instance of Y first.
3. Process all instance variable declarations in the order in which they appear in the class.
4. Process all instance initializers in the order in which they appear in the class.
5. Initialize the constructor, including any overloaded constructors referenced with this().
Therefore, when page 304 says
Per the fourth rule, we initialize the constructors.
it should instead say
Per the fifth rule, we initialize the constructors.
Secondly, also on page 304,
Per the third and fourth rules, H is printed on line 25, and G is printed on line 23, respectively.
should be changed to
Per the fourth and fifth rules, [...]
because on line 25 an
instance initializer (fourth rule) is executed and line 23 is part of a
constructor initialization (fifth rule).
The code snippet for reference: