Using “this” with class name

前端 未结 7 1520
暗喜
暗喜 2020-11-30 18:19

I am doing Android programming and was learning about Intents, when I saw a constructor that, to my C# trained mind, seemed funky. The call was:

Intent myI         


        
7条回答
  •  甜味超标
    2020-11-30 18:21

    The syntax "Classname.this" is for inner classes. If you want to refer to the enclosing instance of type "Outerclass" then you do it as "Outerclass.this".

    NextActivity.class is simply the Class object that describes class "NextActivity".

提交回复
热议问题