this为一系统资源,只允许用户读而不允许写,它存放当前对象的地址(引用)。
this变量有以下作用:
1. 构造方法重用:
public class Rectangle{ public Rectangle(Shape size,Location at){ public Rectangle(Location at) { public Rectangle(Shape size) { public Rectangle() { |
2、消除歧义:
Location{ private int x; private int y; public Location(int x,int y) { this.x=x; this.y=y; } …… } |