![]() |
![]() |
![]() |
![]() |
![]() |
|
In principle, you could rewrite counter = counter - 1, using an
augmented assignment operator, as counter -= 1. You are not likely
to see such expressions, however, because Java offers a still
more-concise shorthand for adding 1 to a variable or for subtracting
1 from a variable. To use the shorthand, you drop the equal-to sign
altogether, as well as the 1, and prefix the variable with the
increment operator, ++, or the
decrement operator, --. Thus,
you can replace counter = counter - 1 by the following expression:
--counter