Note the use of the this keyword

1, when local variables and member variables of the same name, java enabled the principle of proximity, in order to distinguish member variables, member variables in the best and then add this (this. Member variables), this is the most important role is to deal with member variables and local variables of the same name issue

For example, set the method (get method does not reflect this regard)

 

 

2, here noted that this refers to the object of p1 (  which calls this, this just means that who on behalf of )

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/jiazhutao/p/11940074.html