【发布时间】:2011-10-25 15:57:49
【问题描述】:
byte b=12;
b >>= 2; // Why is this legal? why does it automatically typecasts?
b = b >> 2; // Why is this illegal if the above is legal
【问题讨论】:
标签: java
byte b=12;
b >>= 2; // Why is this legal? why does it automatically typecasts?
b = b >> 2; // Why is this illegal if the above is legal
【问题讨论】:
标签: java
b>>=2;
和
b = (byte) (b>> 2);
15.26.2 Compound Assignment Operators
E1 op= E2 形式的复合赋值表达式是等价的 到 E1 = (T)((E1) op (E2)),其中 T 是 E1 的类型,除了 E1 只评估一次。
【讨论】: