Sometimes we all want to change our age. First, they don't want to sell you cigarettes or beer. Then your hair starts thinning and your back aches! A programmer may not have control over time, but he or she has total control over data in programs. In this task, we correct an error so that a Person object's age variable receives a different value.
This age doesn't work for me…
- 4
Locked
Comments (33)
- Popular
- New
- Old
You must be signed in to leave a comment
Elias Daniel Hung
16 July 2021, 03:29
Keep on, keep trying, if you feel like you can't, seek help and you will find it ... in the midst of this pandemic that takes away our loved ones, and the problems you may have, fight for a better future, cheer up. ..
0
Aron
30 June 2021, 18:53
key line in the lecture "The local variable masks the instance variable".
so you need to use the keyword this to refer to the age instance variable
0
Pahunchik
8 March 2021, 14:44
Thanks to iqbalhussain
0
Edddieg
7 June 2020, 17:57
- age shouldn't be the parameter in the adjustAge method
- age belongs t the person class
- so just change the parameter name of the adjudge method
- it should work
- hope this helps
+2
kar-fai chow
17 November 2020, 09:24
unfortunately, not in this case
One of the requirement is to force the parameter to be named "age"
0
Sinisa
15 February 2021, 11:01
Yes it is the requirement, however generally speaking I think it is better to give unique variable names as Edddieg suggested to exclude the unnecessary code debugging...
0
Liew
16 April 2020, 03:50
easy, you just need to understand the age belongs to where, the class or the method and how to change it.
+1
locanto B
10 April 2020, 19:16
Not able to view the Requirements under Conditions tab. Created the Test.java file as per instructions to check whether requirements section will display/load the requirement, but encountered the same issue.
0
Alex Vypirailenko Java Developer at Toshiba Global Comme
11 April 2020, 09:27
It's because you've reached the end of the translated content. In order to proceed, you will need to continue on the English language version of the course. However, you will also need a subscription.
0
andy 6473
6 April 2020, 15:35
please understand the concept of static and non static variable . this will help you in solving the problem
+1
~mK
19 December 2019, 00:47
Hi
I am getting the right answer. The method is increasing the age.
But I am getting an error.
plz help
+1
Janusz
28 October 2019, 21:53
It's thanks to the hints of Pushkar Patil
0
luis_rmr
6 October 2019, 15:03
Two key lecture points to remember in order to resolve this:
- An instance variable can't be accessed from static methods
- When you declare a variable inside a method, that variable exist only in that method and takes precedence even if there's an instance variable with that name.
0