String转int
String s = "1314";
int i;
try {
i = Integer.parseInt(s);
System.out.println("i 为 int 类型 "+i);
}
catch (NumberFormatException e) {
i = 0;
System.out.println("原始数据错误");
}
![](https://i-blog.csdnimg.cn/blog_migrate/a97b06f12b8e90da1894059790a667d0.png)
int转String
int i = 1415;
String s = Integer.toString(i);
System.out.println("String类型 "+s);
![](https://i-blog.csdnimg.cn/blog_migrate/ddd0cf567e88deebb7f0a7ef2a2f34ee.png)