基本运算符:

算术运算符:+,-, * ,  / ,% ,++ , - -     
赋值运算符:=                                         
关系运算符:<,>,<=,>=,==,!=instanceof
逻辑运算符:&&,||,!                         
位运算符:&,|,^,~,>>,<<,>>>           
条件运算符:?:                                    
扩展赋值运算符:+=,-=,*=,/=            


 

 1 package operator;
 2 
 3 public class Demo1 {
 4     public static void main(String[] args) {
 5         //二元运算符
 6 
 7         //ctrl+D:复杂当前行到小一行
 8         int  a=10;
 9         int  b=20;
10         int c=25;
11         int d=25;
12         System.out.println(a+b);
13         System.out.println(a-b);
14         System.out.println(a*b);
15         System.out.println(a/(double)b);
16 
17     }
18 }
 1 package operator;
 2 
 3 public class Demo2 {
 4     public static void main(String[] args) {
 5         long a=12131312312L;
 6         int b=123;
 7         short c=10;
 8         byte d=8;
 9 
10         System.out.println(a+b+c+d);          //Long
11         System.out.println(b+c+d);            //int
12         System.out.println(c+d);              //int
13     }
14 }
 1 package operator;
 2 
 3 public class Demo3 {
 4     public static void main(String[] args) {
 5         //关系运算符返回的结果:  正确,错误   <布尔值>
 6 
 7         int a =10;
 8         int b =20;
 9         int c =21;
10 
11         System.out.println(a<b);
12         System.out.println(a>b);
13         System.out.println(a==b);
14         System.out.println(a!=b);
15         System.out.println("======================");
16         //取余,也就模运算
17         System.out.println(c%a);//  c / a     21 / 10  =2.....1
18 
19     }
20 }

 

posted on 2021-04-24 14:27  帆吖  阅读(43)  评论(0)    收藏  举报