Inner classes are used for situations where an object can not exists without another object. For instance a Map has Map.Entries (both interfaces but for this example you can view them as classes). The Map.Entry cannot exists without a Map. It has no purpose to live without it. Therefor it's made an inner interface.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
There are several compelling reasons for using nested classes, among them:
* It is a way of logically grouping classes that are only used in one place.
* It increases encapsulation.
* Nested classes can lead to more readable and maintainable code.
PS: Non-static nested classes are called inner classes.