0

int x = 14; System.out.println(x++);

I do not understand why this is 14. If you are adding 1 to X which is 14 shouldn't be 15? Even in the lesson is said that x would equal 15 or 35 in lesson when it is a postfix.

24th Dec 2016, 11:32 PM
Jessica Tate
Jessica Tate - avatar
5 ответов
+ 3
Yes. It will be 15, but AFTER the operation. ++x will show 15 , and be 15 also, but if will be added 1 BEFORE the operation (operation like print, or even mathematics ones.)
24th Dec 2016, 11:57 PM
Nahuel
Nahuel - avatar
+ 1
the x++ operation increments the variable after its used in println (postfix). To print 15 use ++x (prefix)
24th Dec 2016, 11:45 PM
Niko Pinnis
Niko Pinnis - avatar
0
int x = 1; do { System.out.println(x); x++; } (x <= );
14th Jul 2021, 3:38 AM
Mbulze Vera Monie
Mbulze Vera Monie - avatar
0
int x = 14; System.out.println(x++); Correct Answer ia 14
7th Sep 2024, 9:22 AM
Budhabhushan Waghmare
Budhabhushan Waghmare - avatar
- 1
What is the output of the following code? int x = 14;
24th Dec 2019, 8:38 PM
Dayah Ali
Dayah Ali - avatar