参考答案:
Java中的包装类(Wrapper Classes)是对基本数据类型(primitive types)的封装,它们允许基本数据类型的值作为对象来使用。Java提供了以下包装类,对应基本数据类型:
Byte:对应基本类型 byte。
byte 类型数据。Short:对应基本类型 short。
short 类型数据。Integer:对应基本类型 int。
int 类型数据。Long:对应基本类型 long。
long 类型数据。Character:对应基本类型 char。
char 类型数据。Double:对应基本类型 double。
double 类型数据。Float:对应基本类型 float。
float 类型数据。Boolean:对应基本类型 boolean。
true 和 falseboolean 类型数据。ArrayList)要求元素是对象,因此需要包装类来存储基本数据类型。1int a = 5; 2Integer b = a; // 自动装箱:基本数据类型转为包装类 3int c = b; // 自动拆箱:包装类转为基本数据类型
最近更新时间:2024-12-09