+ 1

If --x and x-- are different arguments, then why do they appear to yeild the same output when ran in Code Playground?

https://code.sololearn.com/cELUWa8ZixVZ/?ref=app

2nd Jan 2018, 2:29 PM
Charles Street
Charles Street - avatar
5 Respostas
+ 16
try replacing x-- with x=x-- ; & when u write ---x replace it with x=--x ; //U will get the difference /* the difference is not visible another line , when we we assign this value to a different variable or its remain unassigned(just incremented or decremented) */
2nd Jan 2018, 3:30 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 15
right @Vadim 👍
2nd Jan 2018, 3:38 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
try this: int x = 0; System.out.println(x++); x=0; System.out.println(++x);
2nd Jan 2018, 2:33 PM
Leander
Leander - avatar
+ 2
In this case there is a difference: int x = 3; while(x > 0) { System.out.println(x--); } int y = 3; while(y > 0) { System.out.println(--y); } See also: https://www.sololearn.com/learn/Java/2141/
2nd Jan 2018, 3:35 PM
Вадим Сухотин (Vadim Sukhotin)
Вадим Сухотин (Vadim Sukhotin) - avatar
+ 1
maybe this helps you to understand 😊
2nd Jan 2018, 2:34 PM
Leander
Leander - avatar