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
Зарегистрируйся сейчас
или Подпишись на будущие тесты