//'56'必须是字符数组:
char[] ch = {'5', '6'};
String s = String.valueOf(ch);
int i = Integer.parseInt(s);
System.out.println(i);
//字符的话:
char ch = '5';
String s = String.valueOf(ch);
int i = Integer.parseInt(s);
System.out.println(i);
//字符串的话直接:
String s = "56";
int i = Integer.parseInt(s);
System.out.println(i);
java 数字字符转换成数字
最新推荐文章于 2023-11-15 14:33:19 发布