Inner Classes.

What are the benefits and disadvantages of using Inner Classes? I like to hear everyone's opinion.
[113 byte] By [kmkiania] at [2007-9-19]
# 1
Advantage: 1. That is a true composition.Disadvantage: 2. Diffcult to trace the code.
angusedisona at 2007-7-8 > top of java,Core,Core APIs...
# 2

advantages:

Does not waste namespace.

Since they have access to private and local (for local nested classes) variables, in some cases the solution without nested classes would be nasty.

Anonymous inners are great to define classes with few simple methods.

disadvantages:

Inconvenient for reuse.

Does not fit well with some other ideas of the language, like cloning.

May create accessors and mutators in the parent class which CAN be considered broken encapsulation and in some cases security risk.

zakariahqa at 2007-7-8 > top of java,Core,Core APIs...
# 3
Anonymous Inner classes are great, I often do this:private Runnable r = new Runnable(){public void run(){//do something}}then use r later in a thread. I don't use inner classes much but they are extremely handy in certain situations.
dgraham1980a at 2007-7-8 > top of java,Core,Core APIs...