java基本數據類型默認值

        boolean t;
	char c;
	byte b;
	short s;
	int i;
	long l;
	float f;
	double d;
        /**
        

1)布爾型    boolean    1個字節(8位)  ture,false    false

2)字節型    byte    1個字節(8位)  -128~127    0

3)短整型    short    2個字節(16位)    -2(的15次方)~2(的15次方)-1    0

4)整形    int    4個字節(32位)    -2(的31次方)~2(的31次方)-1    0

5)長整形    long    8個字節(64位)    -2(的63次方)~2(的63次方)-1    0

6)字符型    char    2個字節(16位)    0~2(的16次方)-1    '\u0000'

7)單精度浮點型    float    4個字節(32位)    1.4013E-45~3.4028E+38    0.0F

8)雙精度浮點型    double    8個字節(64位)    4.9E-324~1.7977E+308    0.0D

*/ @Test public void defaultVal() { System.out.println("boolean " + t); System.out.println("char " + c); System.out.println("byte " + b); System.out.println("short " + s); System.out.println("int " + i); System.out.println("long " + l); System.out.println("float " + f); System.out.println("double " + d); }輸出結果:
boolean  false
char  
byte  0
short  0
int  0
long  0
float  0.0
double  0.0

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章