File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Inner Class inheritance super

Siva kandasamy
Ranch Hand

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



Dirk Schreckmann

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

Joined: Oct 01, 2001
Posts: 2968

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:
subject: Inner Class inheritance super
It's not a secret anymore!