java整型与字符型的相互转换

1.将字符串转换成整数int

(1)int i = Integer.parseInt([String]);

(2)int i = Integer.valueOf(str).intValue();

同时,将字符串转换为double、float、long的方法也如此类似。

2.将整数转换为字符串String

(1)String s = String.valueOf(i);

(2)String s = Integer.toString(i);

(3)String s = "" + i;

本文参考:https://www.cnblogs.com/shootercheng/p/6022411.html

扫描二维码关注公众号,回复: 4237370 查看本文章

猜你喜欢

转载自blog.csdn.net/lixinyu306/article/details/84524436