This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Good Question. Generally inner classes are used to create anonymous local classes.For example someone wants to create a Thread object and pass a Runnable object in it.
The code is a bit complex to look at but you can create thread objects like this without even needing to implement Runnable.Another important usage of inner classes is in awt events. Inner anonymous classes come of great use while designing complex action events.
Inner classes are also frequently used for adding action and event listeners, for example in a Swing application (e.g. a button). This then reduces the need for one action performed method to have to check which button was pressed and assigning the relevant action.
be a well encapsulated person, don't expose your privates, unless you public void getWife()!