The this Keyword
In our Person class, we saw the following line in our constructor:
age = myAge;
In this line, as we saw earlier, we are setting the age variable in our current object to the new value, myAge, which is passed in as a parameter. Sometimes, we wish to be explicit about the object we are referring to. When we want to refer to the properties in the current object we are dealing with, we use the this keyword. As an example, we could rewrite the preceding line as follows:
this.age = myAge;
In this new line, this.age is used to refer to the age property in the current object we are dealing with. this is used to access the current object's instance variables.
For example, in the preceding line, we are setting the current object's age to the value that's passed into the constructor.
In addition to referring to the current object, this can also be used to invoke a class' other constructors if you have more than one constructor.
In our Person class, we will create a second constructor that...