教程集 www.jiaochengji.com
教程集 >  脚本编程  >  java  >  正文 Overloading overriding runtime type and object ori

Overloading overriding runtime type and object ori

发布时间:2019-02-18   编辑:jiaochengji.com
教程集为您提供Overloading overriding runtime type and object ori等资源,欢迎您收藏本站,我们将为您提供最新的Overloading overriding runtime type and object ori资源
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.

您可能感兴趣的文章:

[关闭]
~ ~