运算符
public class BJDemo {
/*
* 比较运算符
* (恒等) != >= <= > <
*/
public static void main(String[] args){
int x = 90, y = 70;
boolean flags;
flags = (xy);
System.out.println(flags); //flags
flags = (x!=y);
System.out.println(flags); //true
flags = (x<=y);
System.out.println(flags); //flags
flags = (x>=y);
System.out.println(flags); //true
flags = (x>y);
System.out.println(flags); //true
flags = (x<y);
System.out.println(flags); //flags
}
}
public class LJDemo {
/*
* 逻辑运算符
* &&(短路与) and: 只有所有值都为真才为真,否则都为假
* ||(短路或) or:只要有真,都是真
* !取反
*/
public static void main(String[] args){
//TODO 自动生成方法存根
boolean x = true, y = false;
System.out.println(x && x);//true&&true true
System.out.println(x && y);//true&&false false
System.out.println(y && x);//false&&true false
System.out.println(y && y);//false&&false false
System.out.println(x || y);//true||false true
System.out.println(x || x);//true||false true
System.out.println(y || y);//false||false false
System.out.println(x || x);//true||true true
}
}
public class DuDemo {
/**
* 赋值运算符:=(赋值) ==(恒等于) !=(不等于) += -= *= /= %=
*/
public static void main(String[] args) {
int a = 10; //赋值
int b = 260;
b += a; //b = b + a;
System.out.println(a); //10
System.out.println(b); //270
b -= a; //b = b-a;
System.out.println(b); //260
b *= a; //b = b * a;
System.out.println(b); //2600
b /= a; //b= b / a;
System.out.println(b); //260
b %= a; //b= b % a;
System.out.println(b); //0
}
}