Java inner class
In Java, the definition of one class is allowed to be located inside another class. The former is called internal class and the latter is called external class.
Inner class is generally used in the class or statement block that defines it. When it is referenced externally, it must be given a complete name. The name of inner cannot be the same as the class name containing it;
Inner class can use the private data of the external class because it is an external class member. Members of the same class can access each other. To access the members of the internal class, the external class needs: the internal class Member or inner class object Members.
Classification: member inner class (static member inner class and non static member inner class), local inner class (without modifier), anonymous inner class
Test. java
Output:
one
two
three
four
Internal class properties:
What is the role of inner classes?
It mainly solves the problem that Java cannot inherit multiple.
Output:
This is the rewritten B method and this is the rewritten C method