第二天补充
package operator;
public class operator {
//运算符
/*
* 算术运算符:
* 赋值运算符:
* 关系运算符:
* 逻辑运算符:
* 位运算符:
* 条件运算符:
* 拓展赋值运算符
*/
public static void main(String[] args) {
// a++ ++a
int a = 1;
int b = a++;
int c = ++a;
System.out.println(b);
System.out.println(c);
System.out.println("-------------------------------------------");
//Math数学类 3^2的次方
double d = Math.pow(3,2);
System.out.println(d);
System.out.println("-------------------------------------------");
//逻辑运算符 //与(and) 或(or) 非(取反)
boolean a1 = true;
boolean b1 = false;
System.out.println("a1&&b1:"+(a1&&b1));//逻辑与运算:两个变量都为真,结果为true
System.out.println("a1||b1:"+(a1||b1));//逻辑或运算:两个变量一个为真,结果为true
System.out.println("!(a1&&b1):"+!(a1&&b1));//如果是真则为假,如果是假则为真
//短路运算
int c1 = 5;
boolean b2 = c1<4&&c1++<4;
System.out.println(c1);
System.out.println(b2);
System.out.println("-------------------------------------------");
//位运算
/*
* << 左移 *2 >> 右移 /2
* */
System.out.println(2<<3);//本身就有一个2 本身2 *2这才是第一个*2*2 得出 2*2*2*2=16
System.out.println("-------------------------------------------");
//条件运算符
int i = 10;
int n = 20;
i+=n; // i = i + n;
i-=n; // i = i - n;
System.out.println(i);
System.out.println("-------------------------------------------");
//输出为1020字符串在前面会把里面的变成字符串类型使用(i+n)里面的数据正常运算不会被当做字符串加在一起
System.out.println(""+i+n);
//输出为30字符串在后面前面的int类型正常运算
System.out.println(i+n+"");
System.out.println("-------------------------------------------");
// x ? y : z 会返回一个结果
//如果x为true,则结果为y,否则为z;
int score = 80;
String str = score>60 ? "及格" : "不及格";
System.out.println(str);//结果为及格
}
}
```java