Java,
分享于 点击 36434 次 点评:170
Java,
1.JAVA基本数据类型:
2.自动转化
// byte 不可自动转换为char,
// short不可以自动转换为char
char mchar ='s';
// short 不可以自动转换为byte
// char 不可以自动转换为byte
byte mbyte = 'c';
// byte 可以自动转换为short
// char 不可以自动转换为short
short mshort = 26;
// byte、char、short可以自动转换为int
int mint;
mint = mchar;
mint = mbyte;
mint = mshort;
// byte、char、short、int可以自动转换为long
long mlong;
mlong = mchar;
mlong = mbyte;
mlong = mchar;
mlong = mint;
// byte、char、short、int、long可以自动转换为float
float mfloat;
mfloat = mchar;
mfloat = mbyte;
mfloat = mshort;
mfloat = mint;
mfloat = mlong;
// byte、char、short、int、long、float可以自动转换为double
double mdouble;
mdouble = mchar;
mdouble = mshort;
mdouble = mbyte;
mdouble = mint;
mdouble = mlong;
mdouble = mfloat;
相关文章
- 暂无相关文章
用户点评