+ 1
If --x and x-- are different arguments, then why do they appear to yeild the same output when ran in Code Playground?
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)
*/
+ 15
right @Vadim 👍
+ 3
try this:
int x = 0;
System.out.println(x++);
x=0;
System.out.println(++x);
+ 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/
+ 1
maybe this helps you to understand 😊