- public static void main(String[] args) {
- // TODO Auto-generated method stub
- byte b1 = 1 + 1;
- //byte b2 = 1; b2 = b2 + 1; //这里是两步运算,中间有一个类型提升的过程,编译错误
- byte b3 = 1; b3 = b3 += 1; //这里是一部运算, b3直接被赋值了运算后的值,中间虚拟机会自动转换
- byte b4 = 1; b4 = ++b4;
-
- System.out.println(b1);
- //System.out.println(b2);
- System.out.println(b3);
- System.out.println(b4);
- }
复制代码
|