This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
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.