75 扩展运算符的自动转换

当char byte short变量参与运算时,会自动转换为int型数据进行运算。

当使用*= += /= -=等扩展运算符进行运算时,会自动进行数据类型转换。

所以:会报错。

short s = 1;
short s1 = 2;
short s2 = s+s1;

  

而:不会报错

short s = 1;
short s1 = 2;
s += s1;

  

猜你喜欢

转载自www.cnblogs.com/Scorpicat/p/12121417.html
75