• 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

Accessing inner class -- error?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What seems to be an error in "Getting in Touch with your Inner Class" (Campfire Stories): You can also instantiate both the outer class and inner class at the same time:


Recreating the whole example in Eclipse, it doesn't pass the syntax checker. According to JCHQ, the syntax is

This compiles and runs for me. Excuse an uppity beginner, but what do you think?
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the article, in the code just above the statement you pointed out, they have the variable with the correct type Outer.Inner. So you are correct. Probably a typo.

Thanks, I'll try to get someone to fix it.
[ January 25, 2005: Message edited by: Barry Gaunt ]
 
Steve Edwards
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Barry,

Thanks, you answered my question. Yes, I see the line you are talking about where Outer o is instantiated first, and then Outer.Inner i from there. The typo's a little more unfortunate since it comes right after the comment:

// Inner i = new Inner();
// NO! Can't instantiate Inner by itself!

I hope my picking comes across in good humor. Actually, the article is the most helpful explanation I've come across and helped a lot. Thank you!

Steve
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another possiblity is that there is an import statement at the top of the source. Something like:

If so, this will make it possible to use the syntax as given:


Layne
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic