I don't understand the postfix thing | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I don't understand the postfix thing

2nd Oct 2016, 1:17 PM
Rookie
2 Answers
+ 2
In postfix the operator comes after the operand. This form follows the Use-then-Change rule i.e it evaluates the value of the operand before the increment/decrement operation. for eg: sum = sum + op++ ; here it increments op by 1; evalutes to the value of op BEFORE it was incremented. but when it comes to prefix the situation is reversed, it uses Change-then-use rule... instead of op++ it uses ++op where it increments op by 1 BUT evalutes to the value of op AFTER it was incremented. Hope it was helpful.....
2nd Oct 2016, 2:45 PM
Treasure
0
prefix means : ++x it shows that the value of x will be first incresed by 1 and then saved it in x. and anotherone is postfix means : x++ it shows that if we use the statement of print as like: system.out.print(x++); it's print current value of x and then the after the value is increased by 1.
3rd Oct 2016, 6:05 PM
Meher jeet
Meher jeet - avatar