//数据类型转换之隐式转换
//小的数据类型与大的数据类型混合运算时,小的数据类型会转换成大的数据类型
//大小关系: int -> long -> float -> double
int b=3;
byte c=4;
b=c+b;// c由byte类型转换为了int类型
System.out.println(b);//7
//在混合运算时间 byte short char不会相互转换,都会自动提升为int,
//数据类型转换:强制转换
float d=1.1f;
c+=(int)d;// c=7
System.out.println(c);//8
//强制转换的类型不能超过其取值范围,
calss test{
public static void main(Syring[] args){
byte b1=3;
byte b2=4;
//byte b3=b2+b1;
//b3 不可以运行 b1与b2是变量,变量存储的值是变化的,在编译时无法判断里面具体的值,相加有可能超过byte的范围
byte b4=3+4;
System.out.println(b4);// 7
}
}