java this keyword

前端 未结 7 1499
野的像风
野的像风 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:41

    this refers to current object.

    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.

提交回复
热议问题