---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 24 Edition"
java_version: 24
chapter: "Chapter 14. Blocks, Statements, and Patterns"
section: "14"
heading: "Chapter 14. Blocks, Statements, and Patterns"
source: https://docs.oracle.com/javase/specs/jls/se24/html/jls-14.html
id: "14"
url: https://jvm.obfuscated.software/jls/se24/14.html
raw: https://jvm.obfuscated.software/jls/se24/14.md
---

# Chapter 14. Blocks, Statements, and Patterns

The sequence of execution of a program is controlled by *statements*, which are executed for their effect and do not have values.

Some statements *contain* other statements as part of their structure; such other statements are *substatements* of the statement. We say that statement S *immediately contains* statement U if there is no statement T different from S and U such that S contains T and T contains U. In the same manner, some statements contain expressions ([§15 (*Expressions*)](15.md)) as part of their structure.

The first section of this chapter discusses the distinction between normal and abrupt completion of statements ([§14.1](14.1.md)). Most of the remaining sections explain the various kinds of statements, describing in detail both their normal behavior and any special treatment of abrupt completion.

Blocks are explained first ([§14.2](14.2.md)), both because they can appear in certain places where statements are not allowed and because one kind of statement, a local variable declaration statement ([§14.4.2](14.4.2.md)), must be immediately contained by a block. Local class and interface declarations ([§14.3](14.3.md)) are not statements, but must also be immediately contained by a block.

Next, a grammatical maneuver that sidesteps the familiar "dangling else" problem ([§14.5](14.5.md)) is explained.

Every statement must be *reachable* in a certain technical sense ([§14.22](14.22.md)).

Sections 14.23-14.29 are unused to allow for the introduction of new kinds of statements in future.

The last section of this chapter ([§14.30](14.30.md)) describes *patterns*, which are used within statements and expressions to conditionally declare and initialize local variables. A pattern gives a concise description of how one value, such as an object, could be composed from one or more other values, denoted by variable declarations. *Pattern matching* attempts to extract one or more values from a given value, as if to decompose it, and uses the extracted values to initialize the variables declared by the pattern.

**Sections:**

- [14.1. Normal and Abrupt Completion of Statements](14.1.md)
- [14.2. Blocks](14.2.md)
- [14.3. Local Class and Interface Declarations](14.3.md)
- [14.4. Local Variable Declarations](14.4.md)
- [14.5. Statements](14.5.md)
- [14.6. The Empty Statement](14.6.md)
- [14.7. Labeled Statements](14.7.md)
- [14.8. Expression Statements](14.8.md)
- [14.9. The if Statement](14.9.md)
- [14.10. The assert Statement](14.10.md)
- [14.11. The switch Statement](14.11.md)
- [14.12. The while Statement](14.12.md)
- [14.13. The do Statement](14.13.md)
- [14.14. The for Statement](14.14.md)
- [14.15. The break Statement](14.15.md)
- [14.16. The continue Statement](14.16.md)
- [14.17. The return Statement](14.17.md)
- [14.18. The throw Statement](14.18.md)
- [14.19. The synchronized Statement](14.19.md)
- [14.20. The try statement](14.20.md)
- [14.21. The yield Statement](14.21.md)
- [14.22. Unreachable Statements](14.22.md)
- [14.30. Patterns](14.30.md)
