What will be the result of compilation and execution of the following code?

public class Fuzz{
    public static void main(String[] args){
        int h = 11; do while(h-->4); while(--h>7);
        System.out.println(h);
    }
}
Explanation
Loops can have no blocks of code with brackets {} as long as they have less than two statements. So, this code is absolutely legal.
Now we only need to remember, that postfix operators are executed AFTER evaluation of variable in the expression and prefix operators - BEFORE.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes