促销 java_原始促销 [Java]
JLS在這里不會“提升到更大的數據類型”,因為它不會為轉移運算符執行二進制數字提升.這由
JLS, Section 15.19涵蓋.
Unary numeric promotion (§5.6.1) is performed on each operand separately. (Binary numeric promotion (§5.6.2) is not performed on the operands.)
一元數字促銷將字節a提升為int.文字4L沒有改變,但無論如何它只需要是一個整體類型.
It is a compile-time error if the type of each of the operands of a shift operator, after unary numeric promotion, is not a primitive integral type.
然后,對于移位,僅使用至少5個有效位來移位int.
If the promoted type of the left-hand operand is int, then only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value 0x1f (0b11111). The shift distance actually used is therefore always in the range 0 to 31, inclusive.
運算符的結果是int,而不是long,因此可以在沒有編譯器錯誤的情況下將其賦值給int.
The type of the shift expression is the promoted type of the left-hand operand.
總結
以上是生活随笔為你收集整理的促销 java_原始促销 [Java]的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java cygwin 乱码_windo
- 下一篇: 就业阶段-java语言进价_day03