Java 常用类型之间的转换

来源:互联网 发布:文学杂志 知乎 编辑:程序博客网 时间:2024/06/03 10:45

char 转 int

int key = Character.getNumericValue(str.charAt(i));  // 1int key = Character.digit(str.charAt(i), 10);  // 2int key = Integer.parseInt(String.valueOf(Str.charAt(3))); // 3

String 转 int

int n = Integer.parseInt(str);

int 转 String

String str = Integer.toString(n);
原创粉丝点击