java如何将char类型的数字转换成int型的数字
public class CharToIntConverter { public static void main(String[] args) { char numChar = '3'; int intNum = numChar - '0'; System.out.println(numChar + ": " + intNum); } }
直接在numChar后面减去’0’即可,输出结果如下:
3: 3
java如何将char类型的数字转换成int型的数字
public class CharToIntConverter { public static void main(String[] args) { char numChar = '3'; int intNum = numChar - '0'; System.out.println(numChar + ": " + intNum); } }
直接在numChar后面减去’0’即可,输出结果如下:
3: 3