Increment and Decrement operators

Incremental operator

The incremental operator ++ increments a value by one.
The value may be a property of an object, an element of an array containing numbers or a variable.

The ++ operator can be positioned before or after the operand on which it operates.
If it is positioned before the operand, that operand is incremented before it is used in a possible expression.
Likewise, if it’s positioned after the operand, the expression is evaluated before the increment is being done.

A couple of examples:

As you probably have guessed, the output of the above code is:

Decremental operator

The decremental operator — decrements a value by one.
If we would take the above code and replace the incremental operator with the decremental operator, and the positive check values with negative ones, like this…

…the output would be:

Search for more Java info on this site here:
Custom Search

Any thoughts or questions?