Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
java_language_specification_7.pdf
Скачиваний:
13
Добавлен:
21.03.2016
Размер:
3.11 Mб
Скачать

8.5 Member Type Declarations CLASSES

8.5 Member Type Declarations

A member class is a class whose declaration is directly enclosed in another class or interface declaration.

A member interface is an interface whose declaration is directly enclosed in another class or interface declaration.

A member interface in a class declaration is implicitly public (§6.6) unless an access modifier is specified.

It is a compile-time error if a member type declaration has more than one of the access modifiers public, protected, and private.

Member type declarations may have annotation modifiers (§9.7) like any other type or member declaration.

The scope and shadowing of a member type is specified in §6.3 and §6.4.

If a class declares a member type with a certain name, then the declaration of that type is said to hide any and all accessible declarations of member types with the same name in superclasses and superinterfaces of the class.

In this respect, hiding of member types is similar to hiding of fields (§8.3).

A class inherits from its direct superclass and direct superinterfaces all the non-private member types of the superclass and superinterfaces that are both accessible to code in the class and not hidden by a declaration in the class.

A class may inherit two or more type declarations with the same name, either from two interfaces or from its superclass and an interface. It is a compile-time error to attempt to refer to any ambiguously inherited class or interface by its simple name.

If the same type declaration is inherited from an interface by multiple paths, the class or interface is considered to be inherited only once. It may be referred to by its simple name without ambiguity.

8.5.1 Static Member Type Declarations

The static keyword may modify the declaration of a member type C within the body of a non-inner class or interface T. Its effect is to declare that C is not an inner class. Just as a static method of T has no current instance of T in its body, C also has no current instance of T, nor does it have any lexically enclosing instances.

242

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]