public class b {
public static void main(String[] args) {
byte b = 1;
long l = 127;
// b = b + l; // 1 if I try this then it does not compile
b += l; // 2 if I try this then it does compile
System.out.println(b);
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用此代码,但我有问题:我不明白为什么b=b+l;不编译,但如果我写,b+=l;那么它编译并运行.
请解释为什么会这样.
Inv*_*r53 13
b+=1用Java自动输入类型; b=b+1才不是.
| 归档时间: |
|
| 查看次数: |
137 次 |
| 最近记录: |