Computer Applications
Distinguish between Postfix decrement and Prefix decrement
Java Operators
29 Likes
Answer
Postfix Decrement | Prefix Decrement |
---|---|
It works on the principle of USE-THEN-CHANGE. | It works on the principle of CHANGE-THEN-USE. |
The decrement operator (--) is written after the operand. | The decrement operator (--) is written before the operand. |
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. | Example:int a = 100; int b = --a; After the execution of these two statements, both a and b will have the value of 99. |
Answered By
17 Likes