文档介绍:×÷Õߣºjeru
email: jeru@
ÈÕÆÚ£º7/3/2001 10:02:33 AM
Objective 3)
Write code to construct instances of any concrete class including normal top level classes inner classes static inner classes and anonymous inner classes.
Inner Classes
¡¤ A class can be declared in any scope. Classes defined inside of other classes are known as nested classes. There are four categories of nested classes.
Top-level nested classes / interfaces
¡¤ Declared as a class member with static modifier.
¡¤ Just like other static features of a class. Can be accessed / instantiated without an instance of the outer class. Can access only static members of outer class. Can¡¯t access non-static instance variables or methods.
¡¤ Very much like any-other package level class / interface. Provide an extension to packaging by the modified naming scheme at the top level.
¡¤ Classes can declare both static and non-static members.
¡¤ Any accessibility modifier can be specified.
¡¤ Nested interfaces are implicitly static (static modifier also can be specified). They can have any accessibility modifier. There are no non-static inner, local or anonymous interfaces.
Non-static inner classes
¡¤ Declared as a class member without static.
¡¤ An instance of a non-static inner class can exist only with an instance of its enclosing class. So it always has to be created within a context of an outer instance.
Outer.