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

# 8.5. Member Class and Interface 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.

A member class may be a normal class ([§8.1](8.1.md)), an enum class ([§8.9](8.9.md)), or a record class ([§8.10](8.10.md)).

A member interface may be a normal interface ([§9.1](9.1.md)) or an annotation interface ([§9.6](9.6.md)).

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

The rules for modifiers of a member class declaration in the body of a class declaration are specified in [§8.1.1](8.1.1.md).

The rules for modifiers of a member interface declaration in the body of a class declaration are specified in [§9.1.1](9.1.1.md).

The scope and shadowing of a member class or interface is specified in [§6.3](6.3.md) and [§6.4.1](6.4.1.md).

If a class declares a member class or interface with a certain name, then the declaration of the member class or interface is said to *hide* any and all accessible declarations of member classes and interfaces with the same name in superclasses and superinterfaces of the class.

In this respect, hiding of member class and interfaces 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 classes and interfaces 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 class or interface 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 class or interface 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 class or interface declaration is inherited from an interface. In such a situation, the member class or interface is considered to be inherited only once, and it may be referred to by its simple name without ambiguity.
