One particularly obvious advantage of using inner classes is that you can inherit a parent class (interface) independently, and that the inheritance of the outer class has no effect on the inheritance of the inner class.
Think in Java describes this:
1 . The inner class can use multiple instances, each with its own state information, and the information of other peripheral objects is independent of each other.
2 . In a single perimeter class, you can have multiple inner classes implement the same interface in different ways, or inherit the same class.
3 . The time to create an inner class object does not depend on the creation of the perimeter class object.
4, the inner class does not have the confusing "is-a" relationship, he is an independent entity.
5 . The inner class provides a better encapsulation, except for the perimeter class, which cannot be accessed by other classes.
The basis of the inner class:
Inner classes can use the members of an external class casually, even if the members in the outer class are private.
When using members or objects in an inner class, use an external class. An inner class member or an outer class. New inner class object.
Also, if we need to generate a reference to a team external class, you can use an external class. This, of course, is generated at the compiler, without any runtime costs.
An inner class that has members inside the inner class of a local inner class anonymous inner class.
Initial learning of Java inner classes