Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Special this

 
Chung Huang
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to me that I am running into the so call special this a lot lately.
What is the socal special this? I know that using this means the implicit reference to the object that the method is invoked on, generally. So what is the deal with the format of classname.this.something-else?
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is actually called a qualified this statement. Here's an example from my mock exam.

The qualified this expression is used within an inner class to access a member of an enclosing class when the enclosing class member is hidden by a member of the inner class.
A similar situation exists when a member of a subclass hides a member of a super class. In that case you would just cast "this" to the type of the superclass.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic