coo*_*ird 18
因为Java拥有的数据类型多于基元.原始数据类型是:
byteshortintlongfloatdoublebooleanchar非原语的数据类型是引用数据类型,它是对象的引用.
一些例子是:
StringIntegerArrayListRandomJFrame以下是两种类型之间差异的简单示例:
int i1 = 10;
Integer i2 = Integer.valueOf(10);
Run Code Online (Sandbox Code Playgroud)
int i1是原始数据类型的变量,int原始int值为10.
Integer i2是一个引用数据类型为的变量Integer,引用Integer包含该值的对象10.