Java运算符(细节)

运算符细节

public class Demo1 {
    
    
    public static void main(String[] args) {
    
    
        int a = 10;
        int b = 20;
        System.out.println(""+a+b);//输出的是1020
        System.out.println(a+b+"");//输出的是30
        byte c = 10;
      //c = c+1;编译错误,Required type:byte,Provided:int
        c +=1; //相当于c=(byte)(c+1)
        System.out.println(c);//输出的是11
    }
}

优先级

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_42713077/article/details/114106006