short 2 byte 2*8bit
char 2 byte 2*8bit
int 32 byte 4*8bit
long 64 byte 8*8bit
float 32 byte 4*8bit 單精度 4字節
double 64 byte 8*8bit 雙精度 8字節
byte,short,int,long都屬於整形數據類型.
而float和double屬於浮點型,而浮點型默認的是double,這就意味着你聲明float t = 1.0是不會通過編譯的,因爲1.0在java中應該是double型的,所以你必須這樣聲明,float t = 1.0F;或者乾脆float t =(float)1.0;
如果是Long對象的話,不能==。
應該用equals()或者compareTo()或者intValue() 或者longValue() 。
如果是基本型的long的話,就可以用==。
Long l6=16L;
Long l7=new Long(16L);
Long l8=new Long(16L);
System.out.println(l6==l7);//false
System.out.println(l8==l7);//false