拆箱和装箱(有了基本数据类型为什么还需要包装类)

1,什么是基本数据类型

java中提供了八个基本的数据类项:int,byte,short,long,float,double,boolean,char

*String不是基本的数据类型

每个基本的数据类型都会有一个对应得包装类

int---Integer

2,装箱和拆箱

装箱,哪基本数据类项转换成对应的包装类型

Integer int1=new Integer(1);

Integer int2=Integer.valueOf(1);

猜你喜欢

转载自www.cnblogs.com/excellencesy/p/9115953.html