Hands-On Design Patterns with Java
上QQ阅读APP看书,第一时间看更新

The this reference

In Java, we can use the this keyword as a reference to the current object. For example, the following code snippet sets the color of the current Bicycle object:

    public void setColor(String theColor) {
this.color = theColor;
}

The preceding setColor method accepts a String parameter and assigns it to the color instance variable of the current object.