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

# 8.4. Method Declarations

A *method* declares executable code that can be invoked, passing a fixed number of values as arguments.

```
MethodDeclaration:
  {MethodModifier} MethodHeader MethodBody

MethodHeader:
  Result MethodDeclarator [Throws]
  TypeParameters {Annotation} Result MethodDeclarator [Throws]

MethodDeclarator:
  Identifier ( [FormalParameterList] ) [Dims]
```

The following production from [§4.3](4.3.md) is shown here for convenience:

```
Dims:
  {Annotation} [ ] {{Annotation} [ ]}
```

The *FormalParameterList* is described in [§8.4.1](8.4.1.md), the *MethodModifier* clause in [§8.4.3](8.4.3.md), the *TypeParameters* clause in [§8.4.4](8.4.4.md), the *Result* clause in [§8.4.5](8.4.5.md), the *Throws* clause in [§8.4.6](8.4.6.md), and the *MethodBody* in [§8.4.7](8.4.7.md).

The *Identifier* in a *MethodDeclarator* may be used in a name to refer to the method ([§6.5.7.1](6.5.7.1.md), [§15.12](15.12.md)).

It is a compile-time error for the body of a class to declare as members two methods with override-equivalent signatures ([§8.4.2](8.4.2.md)).

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

The declaration of a method that returns an array is allowed to place some or all of the bracket pairs that denote the array type after the formal parameter list. This syntax is supported for compatibility with early versions of the Java programming language. It is very strongly recommended that this syntax is not used in new code.

**Sections:**

- [8.4.1. Formal Parameters](8.4.1.md)
- [8.4.2. Method Signature](8.4.2.md)
- [8.4.3. Method Modifiers](8.4.3.md)
- [8.4.4. Generic Methods](8.4.4.md)
- [8.4.5. Method Result](8.4.5.md)
- [8.4.6. Method Throws](8.4.6.md)
- [8.4.7. Method Body](8.4.7.md)
- [8.4.8. Inheritance, Overriding, and Hiding](8.4.8.md)
- [8.4.9. Overloading](8.4.9.md)
