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

public class Main {
    public static void main (String []args) {
        int i = 0;
        i += i++;
        System.out.println(i);
    }	
}
Explanation
JLS $15.7.1. Compound assignment operator is equivalent to i = i + i++ and is executed accordingly.
i will be incremented after evaluating the expression but before the assignment.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты