+ 1

int x = 3; while(x > 0) { System.out.println(x); x--; } /* Outputs 3 2 1 */

in this code, shouldn't the value of x remain 3 when it is compared with 0 for the 2nd time as it is post decrement.

6th Aug 2018, 11:49 AM
Saurabh Negi
Saurabh Negi - avatar
2 Answers
0
on line x-- , it will be 3..post that line, x becomes 2..
6th Aug 2018, 12:06 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
Fuck you SoloLearn
17th Jul 2024, 5:21 PM
Babu Patel
Babu Patel - avatar