+ 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
2 Réponses
+ 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
+ 1
I think the ASCII value of 2 was added to 8.