0
what could be the output of below snippet
int x = 5; int y = x-- - 1; System.out.println(x); System.out.println(y);
3 Respostas
+ 1
for better understanding, you have to treat like
int x=5;
int y=(x--)-1;
x having post decrement, so first it's excutes
y= x-1;
then it's excutes x=x-1;
System.out.println(x); //4
System.out.println(y); //4
0
The otput values of bot are 4.
But you can try these snippest on some internet online compilator. for example
http://ideone.com/
0
4