标签:operation code a* 运算 print pre 布尔值 ble short
1 package operation; 2 3 public class Demo1 { 4 public static void main(String[] args) { 5 //二元运算符 6 //Ctrl+D :复制当前行到下一行 7 int a=10; 8 int b=20; 9 int c=30; 10 int d=40; 11 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 =============================================================== 19 package operation; 20 21 public class Demo2 { 22 public static void main(String[] args) { 23 24 // 运算结果按照类型的优先级 25 // 类型转换:byte、short、char用运算符运算后自动转型为int类型 26 long a =123123123123L; 27 int b =123; 28 short c =10; 29 byte d =8; 30 31 System.out.println(a+b+c+d);//long 32 System.out.println(b+c+d);//int 33 System.out.println(c+d);//int 34 35 //关系运算符f返回的结果:正确,错误 布尔值 36 37 int a2 = 10; 38 int b2 = 20; 39 int c2 = 22; 40 //取余,模运算 41 System.out.println(c2%a2); 42 43 System.out.println(a2>b2); 44 System.out.println(a2<b2); 45 System.out.println(a2==b2); 46 System.out.println(a2!=b2); 47 48 49 } 50 }
标签:operation code a* 运算 print pre 布尔值 ble short
原文地址:https://www.cnblogs.com/summerday0903/p/14369923.html