如何将字符转换为其数字编码值?
我使用的代码是
public class Q1A {
int toInt(char character){
int getInt = toInt(character);
return getInt;
}
}
抱歉,如果我的问题很难理解
最佳答案
你只需要
int toInt(char character){
int i = (int) character; // this will gives int value(ASCII) of char.
return i;
}
或者你可以简化为
int toInt(char character){
return (int) character;
}
您也可以使用Character.getNumericValue(c)
来获取数值。更多关于Character.getNumericValue(c)
关于Java字符到数字编码的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26229933/