温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

java的类型转换

发布时间:2020-08-11 08:35:19 来源:ITPUB博客 阅读:97 作者:rx19841025 栏目:编程语言

有关int与string的互转

[@more@]

如何将字串 String 转换成整数 int?

A. 有两个方法:

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

2). int i = Integer.valueOf(my_str).intValue(); 注: 字串转成 Double, Float, Long 的方法大同小异.

如何将整数 int 转换成字串 String ?

A. 有叁种方法: 1.) String s = String.valueOf(i);

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

3.) String s = "" + i; 注: Double, Float, Long 转成字串的方法大同小异.

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI