page contents

自动装箱与拆箱?

轩辕小不懂 发布于 2022-08-30 15:30
阅读 736
收藏 0
分类:Java开发
4198
Nen
Nen
- 程序员

装箱:将基本类型用它们对应的引用类型包装起来;

拆箱:将包装类型转换为基本数据类型;

//自动装箱

Integer total = 99; //系统自动执行了Integer total = Integer.valueOf(99);

//自定拆箱

int totalprim = total;  //系统自动执行了int totalprim = total.intValue();

请先 登录 后评论