- 1

What output results from the following code? int x = 14; System.out.println(x++); Output is 15 Still showing wrong ans.

https://www.sololearn.com/discuss/493679/?ref=app

27th Jun 2017, 6:06 PM
Ashwin Sengupta
13 Answers
+ 2
Definitely 14. The value is assigned before the increment.
27th Jun 2017, 7:40 PM
Bagshot
Bagshot - avatar
+ 1
ie. change to ++x for the answer to be 15
27th Jun 2017, 7:50 PM
Russel Reeder
Russel Reeder - avatar
0
15 is correct.
27th Jun 2017, 6:09 PM
AgentSmith
0
The good output i think is 14, cause the "x++" first use the previous value of x to do what u want, then increments the variable. So it will output 14, then increments the value of x to 15.
27th Jun 2017, 6:33 PM
BenjiSolo
BenjiSolo - avatar
0
If it is showing 15, that's because you need to remember that println is a function. If I pass the value of (x++) onto a function, then the input is fifteen.
27th Jun 2017, 8:19 PM
Keto Z
Keto Z - avatar
0
output is 14 but the system stores 15
9th Jul 2017, 9:36 AM
Aman Keshri
Aman Keshri - avatar
0
In the number 15 and 14 1 is green and 4 or 5 is red i thought then 1 is the right answer so when I typed 1 it was green but said it is wrong so it might be 1 and a variable
5th Jun 2018, 8:54 PM
Hacker
Hacker - avatar
0
The Answer is 14
10th Nov 2018, 3:34 AM
Orkhan Miralayev
Orkhan Miralayev - avatar
0
answer in 14
10th May 2019, 9:53 AM
khan kamrul islam
khan kamrul islam - avatar
- 1
but its showing wrong
27th Jun 2017, 6:10 PM
Ashwin Sengupta
- 1
thnx to benji solo
28th Jun 2017, 2:54 AM
Ashwin Sengupta
- 1
cool
28th Jun 2017, 7:47 AM
BenjiSolo
BenjiSolo - avatar
- 2
What is it showing? And if you post your code in the playground, I could see for myself and let you know.
27th Jun 2017, 6:15 PM
AgentSmith