- 2
What is the output?
int i = 5; System.out.println(i++); System.out.println(++i);
2 ответов
+ 1
This is Java. Why it has a c++ tag?
the output is :
// 5
// 7
- 1
i++ will perform the increment AFTERWARDS, so you get 5 on that one and move along with its value changed to 6.
++i performs the increment BEFORE, so its value becomes 7 and then is printed