+ 2

Can anyone please explain how this output is achieved

public class Program { public static void main(String[] args) { int b=8; char a='2'; System.out.println(a+b); } } Output:58

5th Feb 2020, 2:51 PM
Charm
Charm - avatar
2 ответов
+ 2
I think you are getting the result in int because it casts char a to int value 🤔 value of 2 in ASCII is 50 Refer to this table to get ASCII values: https://www.asciitable.xyz/images/ascii-table.png
5th Feb 2020, 2:59 PM
HNNX 🐿
HNNX 🐿 - avatar
+ 1
I think the ASCII value of 2 was added to 8.
5th Feb 2020, 2:54 PM
KnuckleBars
KnuckleBars - avatar