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

Moderator: admin

Post Reply
flex567
Posts: 112
Joined: Mon Apr 02, 2018 8:40 am
Contact:

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

Post by flex567 » Sat Sep 22, 2018 2:51 am

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.

admin
Site Admin
Posts: 7551
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sat Sep 22, 2018 7:24 am

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.
If you like our products and services, please help us by posting your review here.

flex567
Posts: 112
Joined: Mon Apr 02, 2018 8:40 am
Contact:

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

Post by flex567 » Sun Sep 23, 2018 3:18 am

There sould be one example with static initializer and instance initializer together. Since questions like that are frequent in exercise.

admin
Site Admin
Posts: 7551
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Mon Sep 24, 2018 12:56 am

Section 9.3.4 has now been added to summarize all the steps with an example. Thank you for your feedback!
If you like our products and services, please help us by posting your review here.

flex567
Posts: 112
Joined: Mon Apr 02, 2018 8:40 am
Contact:

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

Post by flex567 » Mon Sep 24, 2018 1:34 am

Is there a way for me to those changes?

admin
Site Admin
Posts: 7551
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Mon Sep 24, 2018 2:13 am

Please check your PM.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests