---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 15 Edition"
java_version: 15
chapter: "Chapter 8. Classes"
section: "8.5"
heading: "8.5. Member Type Declarations"
parent: "Chapter 8. Classes"
source: https://docs.oracle.com/javase/specs/jls/se15/html/jls-8.html#jls-8.5
id: "8.5"
url: https://jvm.obfuscated.software/jls/se15/8.5.html
raw: https://jvm.obfuscated.software/jls/se15/8.5.md
---

# 8.5. Member Type Declarations

A *member class* is a class whose declaration is directly enclosed in the body of another class or interface declaration ([§8.1.6](8.1.6.md), [§9.1.4](9.1.4.md)).

A *member interface* is an interface whose declaration is directly enclosed in the body of another class or interface declaration ([§8.1.6](8.1.6.md), [§9.1.4](9.1.4.md)).

The accessibility of a member type declaration in a class is specified by its access modifier, or by [§6.6](6.6.md) if lacking an access modifier.

It is a compile-time error if the same keyword appears more than once as a modifier for a member type declaration in a class, or if a member type declaration has more than one of the access modifiers `public`, `protected`, and `private` ([§6.6](6.6.md).)

The scope and shadowing of a member type is specified in [§6.3](6.3.md) and [§6.4](6.4.md).

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](8.3.md)).

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.

It is possible for a class to inherit more than one member type with the same name, either from its superclass and superinterfaces or from its superinterfaces alone. Such a situation does not in itself cause a compile-time error. However, any attempt within the body of the class to refer to any such member type by its simple name will result in a compile-time error, because the reference is ambiguous.

There might be several paths by which the same member type declaration is inherited from an interface. In such a situation, the member type is considered to be inherited only once, and 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.

It is a compile-time error if a `static` class contains a usage of a non-`static` member of an enclosing class.

A member interface is implicitly `static` ([§9.1.1](9.1.1.md)). It is permitted for the declaration of a member interface to redundantly specify the `static` modifier.
