The this
refers to the current instance of an object. So, in your example:
public void setAge(int age)
{
this.age = age;
}
The use of this
in the setAge
setter means we are referring to the instance variable age
in the this.age
and setting that equal to the value of the parameter age
. This means this.age
and age
refer to different variables.