This age doesn't work for me…

  • 4
  • Locked
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.
You can't complete this task, because you're not signed in.
  • Popular
  • New
  • Old
You must be signed in to leave a comment
EdddiegLevel 9 , Providence
7 June, 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
LiewLevel 10
16 April, 03:50
easy, you just need to understand the age belongs to where, the class or the method and how to change it.
andy 6473Level 7 , Bangalore
6 April, 15:35
please understand the concept of static and non static variable . this will help you in solving the problem
~mKLevel 7 , Princeton, NJ
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
JanuszLevel 11 , Radomsko
28 October 2019, 21:53
It's thanks to the hints of Pushkar Patil
luis_rmrLevel 5 , San Ramon
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.
QevivLevel 6 , Katowice
28 September 2019, 10:21
After 30 tries i understood >.> wellll
Raj MishraLevel 8 , India
31 August 2019, 13:10
public class Solution { public static void main(String[] args) { Person person = new Person(); //System.out.println("Age: " + person.age); person.adjustAge(person.age); System.out.println("Adjusted age: " + person.age); } public static class Person { public int age = 20; public void adjustAge(int age) { age = age + 20; System.out.println("The age in adjustAge() is " + age); } } } How to meet the last point which is failing?
Clarence L MackeyLevel 4 , Fresno
23 August 2019, 07:23
a bunch of confusing methods and calls that took a looooong time to partially understand. Still, I do appreciate the mental gymnastics and did gain a deeper understanding of calling methods.
Rainer Ricardo RodriguesLevel 4 , Mumbai
26 June 2019, 08:19
Just a small doubt , how to display the runtime screen on the IntelliJ IDE?