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

# 8.8. Constructor Declarations

A *constructor* is used in the creation of an object that is an instance of a class ([§12.5](12.5.md), [§15.9](15.9.md)).

```
ConstructorDeclaration:
  {ConstructorModifier} ConstructorDeclarator [Throws] ConstructorBody

ConstructorDeclarator:
  [TypeParameters] SimpleTypeName ( [ReceiverParameter ,] [FormalParameterList] )

SimpleTypeName:
  TypeIdentifier
```

The rules in this section apply to constructors in all class declarations, including enum declarations and record declarations. However, special rules apply to enum declarations with regard to constructor modifiers, constructor bodies, and default constructors; these rules are stated in [§8.9.2](8.9.2.md). Special rules also apply to record declarations with regard to constructors, as stated in [§8.10.4](8.10.4.md).

The *SimpleTypeName* in the *ConstructorDeclarator* must be the simple name of the class that contains the constructor declaration, or a compile-time error occurs.

In all other respects, a constructor declaration looks just like a method declaration that has no result ([§8.4.5](8.4.5.md)).

Constructor declarations are not members. They are never inherited and therefore are not subject to hiding or overriding.

Constructors are invoked by class instance creation expressions ([§15.9](15.9.md)), by the conversions and concatenations caused by the string concatenation operator `+` ([§15.18.1](15.18.1.md)), and by explicit constructor invocations from other constructors ([§8.8.7](8.8.7.md)). Access to constructors is governed by access modifiers ([§6.6](6.6.md)), so it is possible to prevent class instantiation by declaring an inaccessible constructor ([§8.8.10](8.8.10.md)).

Constructors are never invoked by method invocation expressions ([§15.12](15.12.md)).

**Example 8.8-1. Constructor Declarations**

```
class Point {
    int x, y;
    Point(int x, int y) { this.x = x; this.y = y; }
}
```

**Sections:**

- [8.8.1. Formal Parameters](8.8.1.md)
- [8.8.2. Constructor Signature](8.8.2.md)
- [8.8.3. Constructor Modifiers](8.8.3.md)
- [8.8.4. Generic Constructors](8.8.4.md)
- [8.8.5. Constructor Throws](8.8.5.md)
- [8.8.6. The Type of a Constructor](8.8.6.md)
- [8.8.7. Constructor Body](8.8.7.md)
- [8.8.8. Constructor Overloading](8.8.8.md)
- [8.8.9. Default Constructor](8.8.9.md)
- [8.8.10. Preventing Instantiation of a Class](8.8.10.md)
