如何在 Java 中将数字的 Unicode 转换为数字本身?
char c ='2';
int x =c;
// here x=unicode of 2, how can I put the 2 itself in x?
最佳答案
最通用的解决方案是
int x = Character.digit(c, 10); // interpret c as a digit in base 10
最快的解决方案是
int x = c - '0'; // subtracts the Unicode representation of '0' from c
关于java - 如何将数字的 Unicode 转换为 Java 中的数字本身?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13884380/