Page 1 of 1

[HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Posted: Sat Sep 22, 2018 2:51 am
by flex567
Is there a complete list of order of initalization for a class in this book?
I think it is something like this:
The order of initialization of a class is:
1. All static constants, variables and blocks.(Among themselves the order is the order in which they appear in the code.)
2. All non static constants, variables and blocks.(Among themselves the order is the order in which they appear in the code.)
3. Constructor.

Re: [HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Posted: Sat Sep 22, 2018 7:24 am
by admin
Actually, Section 9.3.1 discusses the object initialization (i.e. order of initialization of an object of a class) and not class initialization. The two are different. Class initialization happens only the first time that a class is used and not every time that an object of that class is created.

Class initialization is discussed in Section 8.3.6.

Based on your query, I have requested the author to improve this section by including the situation where a class has a superclass as well.

thank you for your feedback!
Paul.

Re: [HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Posted: Sun Sep 23, 2018 3:18 am
by flex567
There sould be one example with static initializer and instance initializer together. Since questions like that are frequent in exercise.

Re: [HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Posted: Mon Sep 24, 2018 12:56 am
by admin
Section 9.3.4 has now been added to summarize all the steps with an example. Thank you for your feedback!

Re: [HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Posted: Mon Sep 24, 2018 1:34 am
by flex567
Is there a way for me to those changes?

Re: [HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Posted: Mon Sep 24, 2018 2:13 am
by admin
Please check your PM.