java中short s=s+1和s+=1的区别
1?)short s=s+1
?
会出现编译错误。s+1的时候,结果会被“升格”为int类型。把int赋给short当然编译错误。
2)s+=1
对于“+=”操作,系统会自动执行类型转换操作,等价于s=(short)s+1。