Java笔记 Operator(Java note operator)

//二元运算符//ctrl+D 复制当前行到下一行int a = 10;int b = 20;int c = 25;int d = 25;System.out.println(a+b);System.out.println(a-b);System.out.println(a*b);System.out.println(a/(double)b);
long a = 123123123L;int b = 123;short c = 10;byte d = 8;System.out.println(a+b+c+d);//LongSystem.out.println(b+c+d);//IntSystem.out.println((double)c+d);//Int//有Long类型的都会是Long 没有Long的都是Int
int a = 10;int b = 20;int c = 21;System.out.println(c%a);//取余(模运算)System.out.println(a>b);System.out.println(a==b);System.out.println(a<b);System.out.println(a!=b);//不等
//++   --    自增  自减int a = 3;int b = a++;  //执行完这行代码后,先给b赋值,再自增//a++相当于a+1System.out.println(a);int c = ++a;//先自增,再赋值System.out.println(a);System.out.println(b);System.out.println(c);//幂运算double pow = Math.pow(3, 2);   //alt+enterSystem.out.println(pow);
boolean a = true;boolean b = false;System.out.println("a && b"+(a && b));//与 andSystem.out.println("a || b"+(a || b));//或 orSystem.out.println("!(a && b)"+!(a && b));//非 取反
<<  *2>>  /2
int a = 10;int b = 20;a+=b;//a=a+ba-=b;System.out.println(a);//输出10//字符串连接符 +System.out.println(""+a+b);//输出1020System.out.println(a+b+"");//输出30
//三元运算符 x ? y : zpublic class Demo08 {    public static void main(String[] args) {        int score = 50;        String type = score <60 ?"不及格" : "及格";        System.out.println(type);
————————
//二元运算符//ctrl+D 复制当前行到下一行int a = 10;int b = 20;int c = 25;int d = 25;System.out.println(a+b);System.out.println(a-b);System.out.println(a*b);System.out.println(a/(double)b);
long a = 123123123L;int b = 123;short c = 10;byte d = 8;System.out.println(a+b+c+d);//LongSystem.out.println(b+c+d);//IntSystem.out.println((double)c+d);//Int//有Long类型的都会是Long 没有Long的都是Int
int a = 10;int b = 20;int c = 21;System.out.println(c%a);//取余(模运算)System.out.println(a>b);System.out.println(a==b);System.out.println(a<b);System.out.println(a!=b);//不等
//++   --    自增  自减int a = 3;int b = a++;  //执行完这行代码后,先给b赋值,再自增//a++相当于a+1System.out.println(a);int c = ++a;//先自增,再赋值System.out.println(a);System.out.println(b);System.out.println(c);//幂运算double pow = Math.pow(3, 2);   //alt+enterSystem.out.println(pow);
boolean a = true;boolean b = false;System.out.println("a && b"+(a && b));//与 andSystem.out.println("a || b"+(a || b));//或 orSystem.out.println("!(a && b)"+!(a && b));//非 取反
<<  *2>>  /2
int a = 10;int b = 20;a+=b;//a=a+ba-=b;System.out.println(a);//输出10//字符串连接符 +System.out.println(""+a+b);//输出1020System.out.println(a+b+"");//输出30
//三元运算符 x ? y : zpublic class Demo08 {    public static void main(String[] args) {        int score = 50;        String type = score <60 ?"不及格" : "及格";        System.out.println(type);