基本数据类型:
byte,int ,short,long ,float ,double ,char ,boolean
包装类型: Byte,Integer,Short,Long,Float,Double,Character,Boolean
装箱:
把基本数据类型转换成对应的包装类型,
Integer i=1;自动装箱,实际上在编译时会调用Integer.ValueOf()
拆箱:
把包装类型转换成对应的基本数据类型;
int j=i;自动拆箱,实际上在编译时调用intValue
为什么有基本数据类型还要有包装类型呢?
因为Java是一个面向对象的语言,而基本的数据类型不具备面向对象的特性。