New course! Every coder should learn Generative AI!
Try a free lesson0
What's the difference between (a++) and (++a)?
Unfortunately I didn't understand the difference between (a++) and (++a) while I was learning the java course..help me please.
2 Answers
+ 3
a++ or a-- is postfix operation, meaning that the value of a will get changed after the evaluation of expression.
++a or --a is prefix operation, meaning that the value of a will get changed before the evaluation of expression.
lets assume this;
a = 4;
b = a++; // first b will be 4, and after this a will be 5
// now a value is 5
c = ++a; // first a will be 6, then 6 will be assigned to c
*From Denim Datta