clarification of “this” keyword in Java

后端 未结 5 1246
陌清茗
陌清茗 2021-01-19 15:17

I have this code copied from Android developers website:

public class ExampleActivity extends Activity implements OnClickListener {
    protected void onCrea         


        
5条回答
  •  滥情空心
    2021-01-19 16:17

    Within an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called. You can refer to any member of the current object from within an instance method or a constructor by using this.

    Reference (from the Sun Java Tutorial):

    • Using the this keyword
    • Understanding Instance and Class Members

提交回复
热议问题