java this keyword

前端 未结 7 1531
野的像风
野的像风 2020-12-11 09:00

I have read that in Java you don\'t have to explicitly bind the this keyword to object, it is done by interpreter. It is opposite to Javascript where you

7条回答
  •  误落风尘
    2020-12-11 09:47

    The Java language specification states:

    When used as a primary expression, the keyword this denotes a value that is a reference to the object for which the instance method was invoked (§15.12), or to the object being constructed.

    I.e. it always points to an object, not a class.

提交回复
热议问题