你好
在网上查了一些资料发现:
在java中,对char, byte和short类型的字符串进行数学算法操作,比如+,-,>>位移操作,都会引发 自动类型提升结果将是int类型,a+b的结果是int, 要将int的值赋给byte就必须进行类型强制转换。
以下这句,是从think in java 3rd中摘出来的,希望对你有帮助。 In char, byte, and short, you can see the effect of promotion with the arithmetic operators. Each arithmetic operation on any of those types produces an int result, which must be explicitly cast back to the original type (a narrowing conversion that might lose information) to assign back to that type.
最后 关于类型的自动提升,java定义若干适用于表达式的类型提升规则: