首页 > 其他 > 详细

包装类

时间:2018-02-22 18:49:19      阅读:183      评论:0      收藏:0      [点我收藏+]



int num = 1;

Integer i = 1;
将Integer转换成String
String string = i.toString();
将String转换成Integer(注意:只能是数字类型的字符串)


java.lang.NumberFormatException: 数字格式异常

String str = "1223432";
int parseInt = Integer.parseInt(str);
System.out.println(parseInt);

装箱: 将基本数据类型 装换成 包装类型
Integer in = Integer.valueOf(1);
拆箱:将包装类型 转换成 基本数据类型
Integer integer = new Integer(10);
int value = integer.intValue();


* 现在 支持自动拆箱和装箱
int num1 = 18;
自动装箱
Integer i1 = num1;

自动拆箱
num1 = i1;

包装类

原文:https://www.cnblogs.com/wlm-boke/p/8459633.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!