---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 24 Edition"
java_version: 24
chapter: "Chapter 8. Classes"
section: "8.6"
heading: "8.6. Instance Initializers"
parent: "Chapter 8. Classes"
source: https://docs.oracle.com/javase/specs/jls/se24/html/jls-8.html#jls-8.6
id: "8.6"
url: https://jvm.obfuscated.software/jls/se24/8.6.html
raw: https://jvm.obfuscated.software/jls/se24/8.6.md
---

# 8.6. Instance Initializers

An *instance initializer* declared in a class is executed when an instance of the class is created ([§12.5](12.5.md), [§15.9](15.9.md), [§8.8.7.1](8.8.7.1.md)).

```
InstanceInitializer:
  Block
```

It is a compile-time error if an instance initializer cannot complete normally ([§14.22](14.22.md)).

It is a compile-time error if a `return` statement ([§14.17](14.17.md)) appears anywhere within an instance initializer.

An instance initializer is permitted to refer to the current object using the keyword `this` ([§15.8.3](15.8.3.md)) or the keyword `super` ([§15.11.2](15.11.2.md), [§15.12](15.12.md)), and to use any type variables in scope.

Restrictions on how an instance initializer may refer to instance variables, even when the instance variables are in scope, are specified in [§8.3.3](8.3.3.md).

Exception checking for an instance initializer is specified in [§11.2.3](11.2.3.md).
