最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Overloading overriding runtime type and object ori
时间:2008-01-12 编辑:简简单单 来源:一聚教程网
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.Inner i = new Outer().new Inner();
・ Just like other non-static features of a class. Can access all the features (even private) of the enclosing outer class. Have an implicit reference to the enclosing instance.
・ Cannot have any static members.
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.Inner i = new Outer().new Inner();
・ Just like other non-static features of a class. Can access all the features (even private) of the enclosing outer class. Have an implicit reference to the enclosing instance.
・ Cannot have any static members.
相关文章
- SolidWorks如何制作棘轮棘爪运动仿真 07-09
- solidworks如何画丝杠模型 06-28
- Mathematica动态控件Slider教程 06-12
- 如何解决SolidWorks找不到零件模型图 05-30
- solidworks弹簧怎么画 solidworks画弹簧的方法 05-23
- solidworks齿轮怎么画 solidworks齿轮画法 05-23