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?
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
posted
0
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 ]
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
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
posted
0
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: