This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Customer Requirements for Developers and have Marcho Behler on-line!
See this thread for details.
The moose likes Java in General and the fly likes referencing outer instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "referencing outer instance" Watch "referencing outer instance" New topic

referencing outer instance

Vlad Patryshev
Ranch Hand

Joined: Jun 30, 2001
Posts: 61
Say, I have
class outer {
int x;
String doStuff();
class inner {
int y;
string doInnerStuff();
Is there a way inside inner, say, in doInnerStuff(), reference not this, which will point to an instance of inner, but the this of the outer class, which would point to an instance inside which inner resides?

Thanks,<br />Vlad
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
Don't quote me on this. I have never tested it, but I think I read it somewhere. I think that 'outer.this' will work.
Vlad Patryshev
Ranch Hand

Joined: Jun 30, 2001
Posts: 61
Thanks! It works!
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: referencing outer instance
It's not a secret anymore!