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.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести