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

# 8.1.7. Class Body and Member Declarations

A *class body* may contain declarations of members of the class, that is, fields ([§8.3](8.3.md)), methods ([§8.4](8.4.md)), classes, and interfaces ([§8.5](8.5.md)).

A class body may also contain instance initializers ([§8.6](8.6.md)), static initializers ([§8.7](8.7.md)), and declarations of constructors ([§8.8](8.8.md)) for the class.

```
ClassBody:
  { {ClassBodyDeclaration} }

ClassBodyDeclaration:
  ClassMemberDeclaration
  InstanceInitializer
  StaticInitializer
  ConstructorDeclaration

ClassMemberDeclaration:
  FieldDeclaration
  MethodDeclaration
  ClassDeclaration
  InterfaceDeclaration
  ;
```

The scope and shadowing of a declaration of a member `m` declared in or inherited by a class C is specified in [§6.3](6.3.md) and [§6.4.1](6.4.1.md).

If C is a nested class, there may be definitions of the same kind (variable, method, or type) and name as `m` in enclosing scopes. (The scopes may be blocks, classes, or packages.) In all such cases, the member `m` declared in or inherited by C shadows the other definitions of the same kind and name.
