After three days I need to ask for help! Where am I going wrong? The error being validated tells me The Person class's adjustAge method should increase the Person's age by 20. The printed output is 40 , I think I did not understand well .. I tried with:
Person person = new Person();
this.age = age;
age = person.age + 20;
and with
this.age = age;
age = age + 20;
inside the adjustAge method, isn't the method increase +20 with my code?
Thank you in advance.package en.codegym.task.jdk13.task04.task0401;
/*
This age doesn't work for me…
*/
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) {
Person person = new Person();
this.age = age;
age = person.age + 20;
System.out.println("The age in adjustAge() is: " + age);
}
}
}