0

HOW THIS OUTPUT X IS 14????

class HelloWorld { public static void main(String[] args) { int x=13; int y=++x; int z=x; System.out.println(z); } } RESULT 14

1st Jan 2022, 11:19 AM
Udhay Shankar.D
Udhay Shankar.D - avatar
4 Respuestas
+ 2
you are incrementing the x value first then storing that in y that's why it's 14
1st Jan 2022, 11:20 AM
Ayan Poddar
Ayan Poddar - avatar
+ 1
>>> int y=++x; This line increments x by 1, so x becomes x+1(13+1) 14
1st Jan 2022, 11:35 AM
Rishi
Rishi - avatar
+ 1
++ (Prefix increment), increment value first amd store in y. So value of x and y is still 14
1st Jan 2022, 5:51 PM
Java Developer
Java Developer - avatar
- 1
To know more check the value type and references type in java. That will help
1st Jan 2022, 11:34 AM
Ayan Poddar
Ayan Poddar - avatar