---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 13 Edition"
java_version: 13
chapter: "Chapter 15. Expressions"
section: "15.14"
heading: "15.14. Postfix Expressions"
parent: "Chapter 15. Expressions"
source: https://docs.oracle.com/javase/specs/jls/se13/html/jls-15.html#jls-15.14
id: "15.14"
url: https://jvm.obfuscated.software/jls/se13/15.14.html
raw: https://jvm.obfuscated.software/jls/se13/15.14.md
---

# 15.14. Postfix Expressions

Postfix expressions include uses of the postfix `++` and `--` operators. Names are not considered to be primary expressions ([§15.8](15.8.md)), but are handled separately in the grammar to avoid certain ambiguities. They become interchangeable only here, at the level of precedence of postfix expressions.

```
PostfixExpression:
  Primary
  ExpressionName
  PostIncrementExpression
  PostDecrementExpression
```

## 15.14.1. Expression Names

The rules for evaluating expression names are given in [§6.5.6](6.5.6.md).

## 15.14.2. Postfix Increment Operator `++`

A postfix expression followed by a `++` operator is a postfix increment expression.

```
PostIncrementExpression:
  PostfixExpression ++
```

The result of the postfix expression must be a variable of a type that is convertible ([§5.1.8](5.1.8.md)) to a numeric type, or a compile-time error occurs.

The type of the postfix increment expression is the type of the variable. The result of the postfix increment expression is not a variable, but a value.

At run time, if evaluation of the operand expression completes abruptly, then the postfix increment expression completes abruptly for the same reason and no incrementation occurs. Otherwise, the value `1` is added to the value of the variable and the sum is stored back into the variable. Before the addition, binary numeric promotion ([§5.6.2](5.6.2.md)) is performed on the value `1` and the value of the variable. If necessary, the sum is narrowed by a narrowing primitive conversion ([§5.1.3](5.1.3.md)) and/or subjected to boxing conversion ([§5.1.7](5.1.7.md)) to the type of the variable before it is stored. The value of the postfix increment expression is the value of the variable *before* the new value is stored.

Note that the binary numeric promotion mentioned above may include unboxing conversion ([§5.1.8](5.1.8.md)) and value set conversion ([§5.1.13](5.1.13.md)). If necessary, value set conversion is applied to the sum prior to its being stored in the variable.

A variable that is declared `final` cannot be incremented because when an access of such a `final` variable is used as an expression, the result is a value, not a variable. Thus, it cannot be used as the operand of a postfix increment operator.

## 15.14.3. Postfix Decrement Operator `--`

A postfix expression followed by a `--` operator is a postfix decrement expression.

```
PostDecrementExpression:
  PostfixExpression --
```

The result of the postfix expression must be a variable of a type that is convertible ([§5.1.8](5.1.8.md)) to a numeric type, or a compile-time error occurs.

The type of the postfix decrement expression is the type of the variable. The result of the postfix decrement expression is not a variable, but a value.

At run time, if evaluation of the operand expression completes abruptly, then the postfix decrement expression completes abruptly for the same reason and no decrementation occurs. Otherwise, the value `1` is subtracted from the value of the variable and the difference is stored back into the variable. Before the subtraction, binary numeric promotion ([§5.6.2](5.6.2.md)) is performed on the value `1` and the value of the variable. If necessary, the difference is narrowed by a narrowing primitive conversion ([§5.1.3](5.1.3.md)) and/or subjected to boxing conversion ([§5.1.7](5.1.7.md)) to the type of the variable before it is stored. The value of the postfix decrement expression is the value of the variable *before* the new value is stored.

Note that the binary numeric promotion mentioned above may include unboxing conversion ([§5.1.8](5.1.8.md)) and value set conversion ([§5.1.13](5.1.13.md)). If necessary, value set conversion is applied to the difference prior to its being stored in the variable.

A variable that is declared `final` cannot be decremented because when an access of such a `final` variable is used as an expression, the result is a value, not a variable. Thus, it cannot be used as the operand of a postfix decrement operator.
