• Post Reply Bookmark Topic Watch Topic
  • New Topic

The "this" keyword  RSS feed

 
Maxwell Xu
Greenhorn
Posts: 18
Chrome IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I have a question about the "this" keyword. I never really understood what it does.

Thanks,

Maxwell
 
Campbell Ritchie
Marshal
Posts: 56540
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now you have read the link Henry posted, you can tell that this has three uses, distinguished syntactically as this, this(...) and this.something.
Note that you often use this.field in an equals() method to distinguish the field of the current object from the similarly‑named field of the other object.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!