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.
from "Thinking in Java": A question that cuts to the heart of inner classes is this: if I just need a reference to an interface, why don�t I just make the outer class implement that interface? The answer is �If that�s all you need, then that�s how you should do it.� So what is it that distinguishes an inner class implementing an interface from an outer class implementing the same interface? The answer is that you can�t always have the convenience of interfaces�sometimes you�re working with implementations. So the most compelling reason for inner classes is:
Each inner class can independently inherit from an implementation. Thus, the inner class is not limited by whether the outer class is already inheriting from an implementation.
Without the ability that inner classes provide to inherit�in effect�from more than one concrete or abstract class, some design and programming problems would be intractable. So one way to look at the inner class is as the completion of the solution of the multiple-inheritance problem. Interfaces solve part of the problem, but inner classes effectively allow �multiple implementation inheritance.� That is, inner classes effectively allow you to inherit from more than one non-interface.