版权声明:作者: Daley Zou ( https://blog.csdn.net/DaleyZou ) 出处: https://blog.csdn.net/DaleyZou/article/details/81904626
方法一:
char ch = '9';
if (Character.isDigit(ch)){ // 判断是否是数字
int num = Integer.parseInt(String.valueOf(ch));
System.out.println(num);
}
方法二:
char ch = '9';
if (Character.isDigit(ch)){ // 判断是否是数字
int num = (int)ch - (int)('0');
System.out.println(num);
}