+1

Can anyone explain more about postfix increment/decrement?

8/28/2019 6:15:46 AM

Innocent Chobesha

5 Answers

New Answer

+4

https://www.sololearn.com/discuss/489143/?ref=app https://code.sololearn.com/c8oH4x1kwx5J/?ref=app https://code.sololearn.com/cH4Pt8zaFR3d/?ref=app https://code.sololearn.com/WropE8SIm4KN/?ref=app

+3

The simplest way to see this in action is the print the increment directly to console. //declare a variable and assign it a value int x = 0; //so here jn the println method we use the original value and print it, straight after it uses the value of x it then increment it by 1 but you dont see this until next time you use x. System.out.println(x++);//output 0 //⬇️here the value of x is now 1 because as soon as x was used in above method straight after the value increased by 1 System.out.println(x);//output 1

+3

Innocent Chobesha no probs. If you look at were the ++ are that when the increment happens ++x increment before using x x++ increment after using x

+1

Thanks for helping

+1

Am really humbled I have learnt something so far Thanks once again