Computer Applications
Distinguish between Postfix increment and Prefix increment
Java Operators
58 Likes
Answer
| Postfix Increment | Prefix Increment |
|---|---|
| It works on the principle of USE-THEN-CHANGE. | It works on the principle of CHANGE-THEN-USE. |
| The increment operator (++) is written after the operand. | The increment operator (++) is written before the operand. |
Example:int a = 99;int b = a++;After the execution of these two statements, a will have the value of 100 and b will have the value of 99. | Example:int a = 99;int b = ++a;After the execution of these two statements, both a and b will have the value of 100. |
Answered By
28 Likes