java 数字字符转换成数字

//'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); 

你可能感兴趣的:(编程相关)