• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Inner class references (this & super)

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The output printed is:
this -> Inner
Outer.this -> Outer
Inner.this -> Inner
Outer.super -> Base
this$0 -> Outer
Please refer to the last 3 print statements.
Are they correctly written? Will they always work as per the
output shown above.
They imply:
1. ClassName.this is equivalent to this.
2. Similar to "this", "super" can also be qualified with a
class name of the enclosing class
3. "this$0" is the reference to the outer-most class.
This seems to be beyond the scope of the exam, but you never know.
 
Straws are for suckers. Now suck on this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic