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.
5 Antworten
+ 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.)
+ 1
the x++ operation increments the variable after its used in println (postfix). To print 15 use ++x (prefix)
0
int x = 1;
do {
System.out.println(x);
x++;
}
(x <=
);
0
int x = 14;
System.out.println(x++);
Correct Answer ia 14
- 1
What is the output of the following code?
int x = 14;