Karesz Mol wrote:
If I'm right the first constructor of C2 calls the second constructor adding as attribute y.
Karesz Mol wrote:
The second constructor of C2 calls the constructor of C1 initializing x. But still i don't get this result x = 4, y = 2, z = 2 of the z. y will be 2 because it's static final and the x will be initialized in C1.
All things are lawful, but not all things are profitable.
All things are lawful, but not all things are profitable.
Step 1. when we create a new object new C2(4); this constructor will be called
Step 2. It will be called the second constructor of C2 by passing the value of x=4 and y=2(from the static y? or what is the passing value of y here?) and the variable z why it get the same value of 2
Step 3. This 2 arguments constructor is called from Step 2, receiving the values of x=4 and y=2, am I right?
Step 4. This calls the constructor of super class C1 which first sets the x to 1 after that the constructor sets the value back to 4
Step 5. Initializing the Static variable y to 2 and the normal variable z to 3
Step 6. Variable z gets the value of 2.
All things are lawful, but not all things are profitable.
Karesz Mol wrote:
So here the parameter v gets to say the value of 5 and will be assigned that value to the instance variable myvalue. So it's the same if I say I hide the instance variable named myvalue? Or again i"m confusing tomato with potato
So is the above example, I'm getting confused because of the naming.
All things are lawful, but not all things are profitable.
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|