If a thing contains another thing, then this is inside a class contains another class;
Internal classification categories: members of the inner class local inner class (anonymous inner classes)
Members of the inner class:
Definition Format:
Modifier class class name {
Modifier class class name {
//
}
}
Note that the internal class uses external, can freely access; disregard for authority; but the external internal, we need the help of internal class object;
Demo: internal name of an external class file class name inside the class $ name;
How to use members of the inner class? There are two ways.
1. Indirect method: Method in which the external class, inner classes, which in turn calls the member function inner classes, and main () method call just outside the class;
Direct Method 2: Formula:
Name = new class name of the object class name ();
The external name of the object class name inner class = new external name class name () .new internal class name ();
Variable access the same name inside the class:
Class to access external variables of the same name inside the class: class name .this outside the outer class member variables;.
Local inner classes: is defined in the internal method: only method currently belongs to use, a method can not be used;
Definition Format:
External modifier class class name {
Modifier class method return type external name (parameter list) {
internal local class class name {
}
}
}
Summary: class privileges modifiers