char转int
1)
char ch = '9'; if (Character.isDigit(ch)){ // 判断是否是数字 int num = Integer.parseInt(String.valueOf(ch)); System.out.println(num); }
2)
char ch = '9'; if (Character.isDigit(ch)){ // 判断是否是数字 int num = (int)ch - (int)('0'); System.out.println(num); }
int转char
int number = 9; char cNumber= (char) (number+'0'); System.out.println("Number "+number+" to char is:"+cNumber);