Language syntax

Increment and decrement

Changes a numeric variable by one. Prefix forms yield the updated value; postfix forms yield the original value. The update can overflow or narrow according to the variable type.

Formal Syntax & Structure

java syntaxjava
++x; x++; --x; x--;

Working Example

Example Snippetjava
public class Main {    public static void main(String[] args) {        int n = 4;        System.out.println(n--);        System.out.println(++n);    }}
Java Reference