Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inner Class inheritance super

 
Siva kandasamy
Ranch Hand
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you uncomment the default constructor of InheritInner, what's the error message that the compiler produces?
 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic