member Inner class:
Feature: The class in which the outer class, the member function, is located.
Difficulty: See comments (related to JVM)
/*when test () is finished, X2 disappears from memory, Inner declaration week, longer than X2, inner is still in the access, giving the feeling as if the life cycle of blood is getting longer solution: let the internal class access the replica of the local variable, that is, this x2 non-x2, two copies of the data disappeared. */ Public classEX10 { Public Static voidMain (string[] args) {Outer out=NewOuter (); Out.text (); }}classouter{intX1 =1; Public voidtext () {intx2 = 2; classInner {Final intx3 = 3;//because it's a replica, it's decorated with fianl . Public voidprint () {System.out.println ("This is the method of the local inner class" + x2);//X2 is the replica above.}} Inner Inner=NewInner (); Inner.print (); }}
Java Internal Class 2 (Member inner Class)