85-
The inner class is divided into 4 kinds
- Static Inner class
- Inside a class, a class decorated by the static keyword is called a static inner class, and its inside can only access static members and methods of the outer class! After compiling, an external class $ inner class is generated. class file that instantiates an inner class object when an external class. Inner class inner= new external class. Inner Class ()
- member Inner class
- defined in an external class, a class that has no static adornment, like a member method, can use all members of an external class. This class is owned by all objects, just like a member. Instantiate in an external class, use the this. Inner class (). Used when instantiating in other classes (new external Class ()). New inner Class (). When accessing external class members in an internal class, use OtterClass.this.member.
- A local inner class is defined in a method, just like a local variable, and can only be used within a method, and only the final variable is accessible in the class
- Anonymous inner class is a kind of local inner class, it has no name, no class keyword definition, no extends, implement keyword, no constructor method, implicitly inherits a class or implements an interface!
Santhiya Park Java SE Training Summary (85-) (inner Class)