Mac本学java·关于三次运算符/字符串连接符/优先级2021.2.12学习记录

三次运算符

  • 条件运算符
   public static void main(String[] args) {
       //三元运算符
       int score = 80;
       String type = score<60 ?"不及格" :"及格";
       System.out.println(type);
   }
}

在这里插入图片描述

字符串连接符

  • 拼接:
   public static void main(String[] args) {
       int a =3;
       int b =4;
       System.out.println(a+=b);
       System.out.println(b);

       //字符串连接符
       int c = 10;
       int d = 20;
       System.out.println(""+c+d);
       System.out.println(c+d+"");

   }
}

在这里插入图片描述
(""+a+b)“”在前面的会产生拼接,否则将不会

运算优先级

  • List item

总述:学完之后要做到代码能自己能看懂代码,自己要多练习哦

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值