0
Why this is so?
int x= 8; System.out.print(++x*3+""+x); Why this is equal to 279?
5 Respostas
+ 1
This equation has four main parts.
Firstly, ++x. This increments x by one and evaluates it, so that part is equal to 9 (8+1).
Second, the 9 is multiplied by 3; this is equal to 27.
Third, you add an empty string (+""). This converts an output into text form, not number form. So now the output is still 27, but as a string.
Lastly, you simply add x, which became equal to 9 from the first part. Since the output is a string, it simply adds "9" to the end of "27".
As a result, the output is 279.
+ 1
No, the two numbers are just joined. Adding an empty string to a number will make it a string, and adding a number to a string just inserts it to the end, so
27 concatinated with 9 = 279
0
++x * 3 = 27
x = 9
27 + "" + 9 = 279
0
But why ""=243?
0
Yes, I understand