aspose file tools*
The moose likes Java in General and the fly likes Inner Class inheritance super Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Inner Class inheritance super" Watch "Inner Class inheritance super" New topic
Author

Inner Class inheritance super

Siva kandasamy
Ranch Hand

Joined: Dec 31, 2002
Posts: 139
Hi there,
I have appended two java code. ie. Chess.java and InheritInner.java
As I understand "super" is the key word to call
upper class constructor. It works fine with "Chess.java".
However, I am not able to understand and apply the same logic
with "InheritInner.java".
Can someone explain logic of super in "InheritInner.java" ?
Why it is not calling outer class constructor "WithInner()"
but inner class constructor "Inner()".
Thanks
siva

====================================================

====================================================

====================================================
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
When you uncomment the default constructor of InheritInner, what's the error message that the compiler produces?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2848
    
  11

Hmm ... interesting example. InheritInner is a subclass of Inner, not WithInner. Therefore it does make sense that constructing "InheritInner" calls a constructor in the superclass Inner. However, since Inner is an inner class (and not static) of WithInner, it cannot exist except as part of a WithInner object. The syntax wi.super(), I admit, baffles me. Apparently what it is doing is allowing the construction of Inner to go on normally within the the context of WithInner. I'm not sure how you would have access to the InheritInner object you created after it's constructed though.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inner Class inheritance super