Meaningless Drivel is fun!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Special this Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Special this" Watch "Special this" New topic

Special this

Chung Huang
Ranch Hand

Joined: Jun 21, 2002
Posts: 56
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?

Let us be showered in the light of confusion!
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
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.

Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="" target="_blank" rel="nofollow">Try my mock exam.</a>
I agree. Here's the link:
subject: Special this
It's not a secret anymore!