您现在的位置是:首页 > 文章详情

Java 常用类库 之 基本类型的包装类

日期:2018-09-24点击:410

http://www.verejava.com/?id=17159727064934

public class Test { public static void main(String[] args) { // 8 种基本数据类型对应的包装类 // byte Byte // short Short // int Integer // long Long // float Float // double Double // char Character // boolean Boolean // // 装箱和拆箱 // 装箱: 将一个基本数据类型转换成包装类 new Integer(int i) // 拆箱: 将一个包装类转换成基本数据类型 int Integer.intValue(); int i = 100; Integer integer = new Integer(i);//装箱 System.out.println(i); System.out.println(integer); int i2 = integer.intValue();//拆箱 System.out.println(i2); // int Integer.parseInt(String s) String str = "200"; int i3 = Integer.parseInt(str); System.out.println(i3); // String Integer.toString(int i) int i4 = 300; String str2 = Integer.toString(i4); System.out.println(str2); // 3. Integer Integer.valueOf(String s) String str3 = "400"; Integer integer2 = Integer.valueOf(str3); System.out.println(integer2); } } 

http://www.verejava.com/?id=17159727064934

原文链接:https://yq.aliyun.com/articles/644702
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章