What is the meaning of “this” in Java?

后端 未结 21 2602
走了就别回头了
走了就别回头了 2020-11-21 05:41

Normally, I use this in constructors only.

I understand that it is used to identify the parameter variable (by using this.something), if i

21条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-21 06:14

    I was also looking for the same answer, and somehow couldn't understand the concept clearly. But finally I understood it from this link

    this is a keyword in Java. Which can be used inside method or constructor of class. It(this) works as a reference to a current object whose method or constructor is being invoked. this keyword can be used to refer any member of current object from within an instance method or a constructor.

    Check the examples in the link for a clear understanding

提交回复
热议问题