代码如下:
//类中声明的变量有默认初始值;方法中声明的变量没有默认初始值,定义时可以不用初始化,但是在使用之前必须先初始化,否则在访问该变量时会出错。
//byte(初始值为0,包装类Byte),short(初始值为0,包装类Short),int(初始值为0,包装类Integer),long(初始值为0L,包装类Long),char(初始值为'u0000',包装类Character),
//float(初始值为0.0f,包装类Float),double(初始值为0,包装类Double),boolean(初始值为false,包装类Boolean),所有引用类型的初始值为null
//基本数据类型的包装类都属于引用类型
public class SPlit{
static byte bt;
static short sh;
static int in;
static long lo;
static char cha;
static float flo;
static double dou;
static boolean bean;
static Byte btt;
public static void main(String args[]){
byte bt2;
System.out.println("byte默认值:"+bt);
System.out.println("short默认值:"+sh);
System.out.println("int默认值:"+in);
System.out.println("long默认值:"+lo);
System.out.println("char默认值:"+cha);
System.out.println("float默认值:"+flo);
System.out.println("double默认值:"+dou);
System.out.println("boolean默认值:"+bean);
System.out.println("我是byte的包装类初始化默认值:"+btt);
//System.out.println(bt2);
}
}