Java Reference
In-Depth Information
Table A.2.3
Increment and decrement operators. x and y are numeric
(floating-point and integer) or char types.
Operator
Description
Post-increment: add 1 to the value.
The value is returned before the increment is made, e.g.
x++
x = 1;
y = x++;
Then y will hold 1 and x will hold 2
Post-decrement: subtract 1 from the value.
The value is returned before the decrement is made, e.g.
x--
x = 1;
y = x--;
Then y will hold 1 and x will hold 0.
Pre-increment: add 1 to the value.
The value is returned after the increment is made, e.g.
++x
x = 1;
y = ++x;
Then y will hold 2 and x will hold 2.
Pre-decrement: subtract 1 from the value.
The value is returned after the decrement is made, e.g.
--x
x = 1;
y = --x;
Then y will hold 0 and x will hold 0.
Search WWH ::




Custom Search