| Author |
instance initializers
|
Arjun Reddy
Ranch Hand
Joined: Nov 10, 2007
Posts: 622
|
|
Hi all, Are instance initializers the labeled loops we write? Or are they something else? Thanks.
|
Be Humble... Be Nice.
|
 |
vidhya suvarna
Ranch Hand
Joined: Aug 28, 2008
Posts: 148
|
|
|
They are instance variables that belong to a class and get initialized before the constructed is called.
|
SCJP 1.4 - 88%<br />SCWCD 1.5 - Preparing
|
 |
Arjun Reddy
Ranch Hand
Joined: Nov 10, 2007
Posts: 622
|
|
|
After the constructor is called right?
|
 |
vidhya suvarna
Ranch Hand
Joined: Aug 28, 2008
Posts: 148
|
|
No, before the constructor is called. Suppose the subclass constructor is called which invokes the superclass constructor then, 1st superclass variables are intialized and the constructor is run. Then controls come to subclass constructor where again 1st subclass variables are intialized and then the constructor run.
|
 |
Bert Bates
author
Sheriff
Joined: Oct 14, 2002
Posts: 8712
|
|
|
how about some sample code?
|
Eliminate fossil fuel subsidies. (If you're not on the edge, you're taking up too much room.)
|
 |
Rekha Srinath
Ranch Hand
Joined: Sep 13, 2008
Posts: 178
|
|
Am I correct if I say that in the following code, "initvar" is an instance initializer? The output of this code is: In Super's constructor. initvar value = 100 Done calling super() in Sub class [ September 28, 2008: Message edited by: Rekha Srinath ]
|
 |
vidhya suvarna
Ranch Hand
Joined: Aug 28, 2008
Posts: 148
|
|
|
Yes Rekha, thats correct.
|
 |
Arjun Reddy
Ranch Hand
Joined: Nov 10, 2007
Posts: 622
|
|
|
Thanks Guys.
|
 |
 |
|
|
subject: instance initializers
|
|
|