Java Reference
In-Depth Information
Pre-increment operator
Preincrement operator “++” is applied to a Variable by writing it
before the variable's name.
Preincrement operator firstly increases the value of variable by 1
and then that incremented value is used in that expression.
We can't apply this operator with final variables or constants.
Pre- decrement Operator
Predecrement operator “--” is applied to a Variable by writing it
before the vatiable's name.
Predecrement operator firstly decreases the value of variable by 1
and then that decremented value is used in that expression.
We can't apply this operator with final variables or constants.
Post-increment operator
Postincrement operator “++” is applied to a Variable by writing it
after the variable's name.
Postincremnt operator firstly use the same non-incremented value
in that expression and after that increases that variable by 1.
We can't apply this operator with final variables or constants.
Post- decrement Operator
Postdecrement operator “--” is applied to a Variable by writing it
after the vatiable's name.
Postdecrement operator firstly use the same non-decremented
value in that expression and after that decreases that variable by 1.
We can't apply this operator with final variables or constants.
Example:
class Increment {