int a=1;
char b=(char)a;
int c=(int)b;
Debugging by load, c is 49 when b is 1, b is 2 and c is 50 initialized I'd appreciate it if you could tell me why this happened
java
When b is 1, c is not 49; when b is 1, c is 49.
One character is stored as a number and replaced with a value in the ASCII table when the type is char.
As you can see from the table above, the letter "1" is 49 in decimal and 0x31 in hexadecimal. The letter '2' is a decimal number of 50.
If you add the number 1 to the letter 1, it becomes the letter 2 Add the number 32 to the letter 'A' to make the letter 'a'.
© 2024 OneMinuteCode. All rights reserved.