Java入門之資料型別

2021-09-12 19:40:23 字數 562 閱讀 7803

數字(整數)

byte 8位 255

short 16位 65536

int 32

long 64位

浮點型 (小數)

float 32位 單精度—7位

double 64位 雙精度—15位

字元char 16位 2位元組 儲存乙個漢字 『a』 『a』 『9』 9 s "hello"字串

邏輯boolean 1bit true真 false假

class data

}

byte->short->int->long->float->double

char->int
自動轉換(小–>大)

int 100 ->float 100.00

強制轉換(大–>小)

float f = 100.20f;

int c =(int)f; //資料丟失

物件型別進行子類和父類的強制轉換較多。

class code

}

java資料型別

整型 型別 儲存大小 取值範圍 int4位元組 2 147 483 648 2 147 483 647 21億 short 2位元組 32 768 32 767 long 8位元組 9 223 372 036 854 775 808 9 223 372 036 854 775 808 byte 1位...

java資料型別

1.整型 int 4位元組 byte 1位元組 short 2位元組 long 8位元組 2.浮點型 float 4位元組 double 8位元組 3.邏輯性 boolean false true 4.字元型 char 2位元組 c語言中時1位元組 類 介面 陣列 在棧中可以直接分配記憶體的資料就是...

Java資料型別

八種基本型別 一 整型 1 int 取值範圍 2147483648 2147483647 儲存位元組 4位元組 2 short 取值範圍 32768 32767 儲存位元組 2位元組 3 long 取值範圍 9223372036854775808 9223372036854775807 儲存位元組 ...