AP® Computer Science A glossary
Increment and decrement operators
Also called: ++, --, post-increment, post-decrement
Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods
The post-increment operator ++ adds 1 to a numeric variable and the post-decrement operator -- subtracts 1.
Appears in the course and exam description (CED): 1.6.A.2
x++ stores the value of x plus 1 back in x; x-- stores x minus 1. The course uses them only as statements on their own, in postfix form.
int lives = 3;
lives++;
lives++;
lives--;
System.out.println(lives);
Output:
4 Learn it properly, with a checkpoint 1.6 Compound Assignment Operators