Inner class:
1, the inner class defined in a class, the instantiation of the inner class is constructed with the method defined by the perimeter class, the inner class object has an implicit reference to the perimeter class, so the inner class can directly access the domain of the perimeter class of the perimeter class, including the private, which is the access privilege of the inner class, which is more powerful than the regular class
2. Inner classes can be hidden from other classes in the same package, but you can refer to the internal class declared by Outerclass.innerclass.
Local inner class:
1. Inner classes move inside the method, and the local inner classes not only have access to the external classes that define them, but can also access only local variables declared as final, compared to the inner classes.
2. The class name cannot be modified by public or private, default
3. The scope acts in the method that declares it, so even if other methods of this class do not know his existence.
Anonymous inner class:
1, omit the class name of the inner class, create only the object of this class, and become the anonymous inner class.
2, you will want to define a callback function, but do not want to write a lot of code, you can consider anonymous inner class.
3. Syntax:
Class outerclass{ //Peripheral class fields and methods ... Supertype Object name = New Supertype (construction params) {//When supertype is an interface, the construction parameter must be empty //inner class domain and method ... }}
4. Methods for obtaining anonymous inner classes: New Object (). GetClass (). Getenclosingclass ()
Static Inner class:
1, the internal class is static modification, so that access privileges are not, when the inner class does not need to access the outer class of the object, it is defined as a static inner class.
Internal classes in the interface:
1, the domain in the interface by default is public static final, so must be initialized immediately, and can no longer be assigned, the internal class defined in the interface is also default public static (the method is default to public)
"Java Foundation" inner class, local inner class, anonymous inner class, static inner class, inner class in interface