KnowledgeBoat Logo

Computer Applications

Distinguish between Postfix increment and Prefix increment

Java Operators

52 Likes

Answer

Postfix IncrementPrefix 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

25 Likes


Related Questions