Internal class + interface solves the problem of no more inheritance in java. External classes can call private members of internal classes (through internal class objects), internal classes can access methods of external classes, members, etc. Internal classes can also be declared differentPermission can only access public or internal classes of default permissions in other classes.
An anonymous inner class is an inner class without a class name, which makes the code simpler, but seems a bit strange (habit is good)
JavaNested classes in the Therefore, compared with the inner class, the two significant similarities of nested classes are:
To create an object of a nested class, you do not need the object of its outer class, so the mysterious reference to the outer class in the inner class disappears in the nested class.
‚It is not possible to access non static members of its peripheral class from objects of nested classes.
Nested classes can include static members or methods.
JavaIn fact, nested classes and nested classes in c++ are actually different. Nested classes in C++ cannot access private members of peripheral classes, but nested classes in Java can access private members of static in their peripheral classes.
Learn reference: https://blog.csdn.net/qq7342272/article/details/6671433