short s1 = 1; s1 = s1 + 1; 有错吗?short s1 = 1; s1 += 1有错吗; Java工程师的修炼之道 2019-04-07 1,208 阅读1分钟 前者不正确,后者正确。对于 shorts1=1;s1=s1+1;由于1是 int 类型,因此 s1+1 运算结果也是 int 型, 需要强制转换类型才能赋值给 short 型。 而 short s1 = 1; s1 += 1;可以正确编译,因为 s1+= 1;相当于 s1 = (short)(s1 + 1);其中有隐含的强制类型转换。