0
Decrement Java
Is there a difference between x-- and --x ?
2 Réponses
+ 6
Yes. --x decrements first and then handles the statement including it. x-- handles the statement first and then decrements x, e.g.:
int x =1;
System.out.println (--x); // prints 0
// value of x is 0 here
int y=1;
System.out.println (y--); // prints 1
// value of y is 0 here
+ 1
Thank you very much. I have always wondered why my answers in challenges werent correct