Java运算符(细节)

时间:2021-02-26 13:17:42   收藏:0   阅读:0

运算符细节

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
  }
}

 

优先级

技术图片

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!