char c = '5';
int n = c - '0';
System.out.println(n);What is printed?
- A
53
- Bcheck_circle
5
- C
0
- D
5.0
Explanation
The Unicode value of '5' is 53 and of '0' is 48; 53 - 48 yields 5, a common way to convert a digit char to its int.
AP Computer Science A· difficulty 3/5
char c = '5';
int n = c - '0';
System.out.println(n);What is printed?
53
5
0
5.0
Explanation
The Unicode value of '5' is 53 and of '0' is 48; 53 - 48 yields 5, a common way to convert a digit char to its int.
Want 10 more like this — adaptive to your weak spots?