Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

referencing outer instance

 
Vlad Patryshev
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! It works!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic