Nested and Inner ClassYou use nested classes to reflect and enforce the relationship between two classes. You should define a class within another class when:
For example, a text cursor makes sense only in the context of a particular text component. As a member of its enclosing class, a nested class has a special privilege: It has unlimited access to its enclosing class's members, even if they are declared private. Like other members, a nested class can be declared static (or not). A static nested class is called just that: a static nested class. A nonstatic nested class is called an inner class. These are illustrated in the following code: class EnclosingClass{
. . .
static class AStaticNestedClass {
. . .
}
class InnerClass {
. . .
}
}See: Nested Class, Inner Class |