运算符

运算符

int c = 5;
boolean a = (c<4)&&(++c<4); //此时 因为 c<4肯定是false所有在与(&&)运算中结果肯定为false 后面的就不执行了
System.out.println(c);      // 这叫短路运算  c还是等于5
System.out.println(a);
 int sum = 10;
 int sum2 =20;

 System.out.println(sum+sum2);       //30
 System.out.println(""+sum+sum2);    //1020       注意这个面试题 注意字符串""的的位置
 System.out.println(sum+sum2+"");    //30

三位运算符

三位运算符 X ? y:z 如果x为true则为y 否则为z

System.out.println("请输入您的成绩");
int score = scanner.nextInt();
System.out.println(score>=60 ? "及格":"不及格");

posted @ 2023-09-25 20:01  记录从头开始学java  阅读(15)  评论(0)    收藏  举报