0
Java question about characters and concatation
When I run this program I get the answer 50. Why is that? Thank you for the feedback! public class Program { public static void main(String[] args) { System.out.println('1' + 1); } }
3 Respuestas
+ 2
on my idea in this code when the compiler come on the '1' use the ASCII number of it and plus to one . hope its usefull !!
+ 1
'1' is character 1. in table of chars it have number of order, here 49, you can this numbers calculate to sum or compare with < > ==. for print 11 use double quotes "1"+1
0
java does not use ASCII but Unicode. Unicode include ASCII.
char c = '\u263A'; //unicode number for smile
int i = c;
System.out.println(c);
System.out.println(i); //9786
System.out.println(c == i); //true