clarification of “this” keyword in Java

后端 未结 5 1238
陌清茗
陌清茗 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

    this refers to the most inner class instance. In your example it refers to ExampleActivity which is of type OnClickListener which is passed in to setOnClickListener.

提交回复
热议问题