• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

use of Outer.this

 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This was a qustion on a mock quiz:
How is an instance of Outer accessed from within an instance of inner within non static classes?
The answer was:
Outer.this
Can someone write some short code depicting this? I have been trying and can't seem to do it. Thanks so much.
Rick
 
Rick Reumann
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I found the answer in Khalid & Mughal's book. Weird, I would have never thought to use 'this' like that since I've always just seen inner classes refer to the outer class members directly.

What threw me off was the phrasing of the question and I'm still not sure it was phrased correctly. I was thinking of somehow getting a handle to an instance variable of the outer class with OuterClassName.this but in the above that's not really what I'm doing.
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here ya go...

Rob
 
reply
    Bookmark Topic Watch Topic
  • New Topic