1. DefinitionA class is defined inside another class. Compiled out are the outer class $ inner class. class. Inner classes are free to use member variables, functions in external classes.
2. How to useThe object that generated the inner class. A.B B = new A (). New B (); A is an outer class and B is an inner class. Calling the member variable of the inner class, direct J, is equivalent to THIS.J calling the member variable of the external class, A.THIS.I initializes the inner class from the program code of the external class, and the inner object is bound to the external object. The program code for an external class can initialize the inner classes it contains by initializing the other class in exactly the same way. With an internal class, you can implement for example: When two buttons perform different tasks, how to get events on two different buttons respectively. This means that the same interface can be implemented in different ways. Internal classes are very convenient for listening to events. Because the same event handlers can be implemented separately for more than one time.
3. How to use anonymous internal classesNew interface, followed by a class implementation result after the interface. It has no name B.fun (new A (){public void DoSomething (){System.out.println ("dosomething");}});
From for notes (Wiz)
14. Internal classes and anonymous classes