• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

use of Outer.this

 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Here ya go...

Rob
 
What is that? Is that a mongol hoarde? Can we fend them off with this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic