Java - 基本数据类型

一 八大基本数据类型

数据类型 大小(bit) 默认值 包装类
byte 8 0 Byte
short 16 0 Short
int 32 0 Integer
long 64 0 Byte
float 32 0.0f Byte
double 64 0.0d Byte
char 16 ‘\u0000 ’ Byte
boolean 1 false Byte

void 不是基本数据类型
引用数据类型主要有 接口 和 数组
String 是引用数据类型

二 基本数据类型自动转换

byte->short , char->int->long

float->double

int ->float

long->double

小可转大,大转小会失去精度。

猜你喜欢

转载自blog.csdn.net/Yolandera/article/details/82622569
今日推荐