KnowledgeBoat Logo

Computer Applications

Distinguish between the following:

Prefix and Postfix Decrement

Java Operators

11 Likes

Answer

Prefix DecrementPostfix Decrement
It works on the principle of first decrement, then use.It works on the principle of first use, then decrement.
It (--) is written before the operand.It (--) is written after the operand.
Example:
int a = 100;
int b = --a;
After the execution of these two statements, both a and b will have the value of 99.
Example:
int a = 100;
int b = a--;
After the execution of these two statements, a will have the value of 99 and b will have the value of 100.

Answered By

6 Likes


Related Questions