Page 63 - CA_Blue( J )_Class10
P. 63
Prefix Operator
As the word "pre" suggests, the increment or decrement calculation is executed before the rest of the other operations,
such as assigning the value. It works on the principle of "increment or decrement before calculation".
• Prefix Increment Operator: The prefix increment operator is written before the operand. First, the operand value is
increased by 1, and then it is used in the expression. For example:
int a = 10, r;
r = ++a * 4;
After the calculation of the expression, the value of a = 11 and r = 44.
a ++a *4 r=result
10 11 44 44
a = 11
After the execution of the program
r = 44
• Prefix Decrement Operator: The prefix decrement operator is written before the operand. First, the operand value
is decreased by 1, and then it is used in the expression. For example:
int b = 5, c;
c = --b * b;
After the calculation of the expression, the value of b = 4 and c = 16
b --b *b c=result
5 4 16 16
b = 4
After the execution of the program
c = 16
Postfix Operator
As the word "post" suggests, the increment or decrement calculation is executed after the rest of the other operations,
such as assigning the value. It works on the principle of "increment or decrement after calculation".
• Postfix Increment Operator: The postfix increment operator is written after the operand. First, the operand value is
used in the expression, and then the value is increased by 1. For example:
int a=10, r;
r = a++ * 4;
After the calculation of the expression, the value of a = 11 and r = 40.
a *4 r=result a++
10 40 40 11
a = 11
After the execution of the program
r = 40
• Postfix Decrement Operator: The postfix decrement operator is written after the operand. First, the operand value
is used in the expression, and then the value is decreased by 1. For example:
int b = 5, r;
r = b-- * b;
61
Operators in Java 61

