java数据类型转换规则
1.除boolean外,其余7类互相转换。
2.小容量---->大容量:自动转换
byte < short < int < long < float < double < char
3.大容量---->小容量:强制类型转换(可能损失精度)
4.当字面值没有超过byte,short,char范围,可以直接赋值。
5.byte,short,char混合运算,都先转换成int类型再运算。
6.多种数据混合运算,先转换成容量最大的类型再运算。
java数据类型转换规则
最新推荐文章于 2023-03-05 09:14:33 发布