Think about what the program is doing.
Fix the programming error so that person.age changes value.
Hint: carefully review the adjustAge method
This age doesn't work for me…
- 3
Locked
Comments (5)
- Popular
- New
- Old
You must be signed in to leave a comment
Le Phan
14 December 2021, 05:44
To help solving the exercises more easier, one completely beginners should know that whenever a variable comes with prefix "static", it would call a "static variable." Otherwise, it is a non-static one. With this in mind and read the examples carefully would help you solve the two exercises efficiently.
0
Aron
11 November 2021, 21:07
Think about variable masking here, one variable is masking the other as they are using the same name, you need to target the correct variable by using the this keyword.
+1
naif
26 November 2021, 20:09
how and where
0
Aron
30 November 2021, 21:41
you have 'age' defined as a class variable and you also have 'age' defined as a parameter variable in the adjustAge method. In the adjustAge method you can access the class variable using this.age & you can access the parameter variable using just age.
+6
Hoist
18 September 2021, 05:06
Great community help without divulging the exact answer. Good learning experience reading all the comments about using > this < which has always been too mysterious.
+1