包装类

来源:互联网 发布:小米手机数据连接不上 编辑:程序博客网 时间:2024/06/12 01:40
1、能够对基本数据类型的值进行包装,使其变成对象类型的值.缓存
byte Byte
short Short -128-127
int Integer......
long Long    .......
float Float
double Double
char Character<127
boolean Boolean
装箱:将基本数据类型的值转换成包装类类型
拆箱:将包装类类型转换成基本数据类型

int ------> Integer :自动装箱
Integer.valueOf(int):
先从缓存(-128---127)中找是否有这样一个Integer实例存在,如果有直接返回
自动拆箱:
typeValue();
Integer.intValue();
Cast:String和基本数据类型之间的转换
基本数据类的包装类型.parseType(s);
String  ----> 基本数据类型的值:
Integer.parseInt(s);
0 0
原创粉丝点击