+ 1
Can anyone explain me this code?
int a = 5; int b = 3; System.out.print(a++ + b++); System.out.print(a + 1 + b); System.out.print(--a + --b); output: 8118
3 Antworten
+ 1
I'll try to explain it - first print statement : postincrement => it is 5 + 3 => 8 ( the values are not saved in "a" and "b"). Second print : the values now are saved in the variables so => 6 + 1 + 4 => 11. The last print here is preincrement operator on both variables => first we change the values in the variables => decrease "a" and "b" by one => 5 + 3 => 8.
+ 1
TheWhiteCat thanks
+ 1
Purvesh Pawar , you are welcome 😉