设为首页 加入收藏

TOP

Overloading overriding runtime type and object ori
2011-06-09 12:55:31 来源: 作者: 【 】 浏览:599次 评论:0
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.
您看到此篇文章时的感受是:
Tags: 责任编辑:administrator
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到QQ空间
分享到: 
上一篇Beginner: Using Servlets to dis.. 下一篇一个用Class.forName()做的动态装..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

相关栏目

最新文章

图片主题

热门文章

推荐文章

相关文章

广告位