1 package 基础题; 2 3 public class Test1 { 4 public static void main(String []args) { 5 System.out.println(\"善学如春起之苗\"); 6 System.out.println(\"不见其增,日有所长\"); 7 System.out.println(\"假学如磨刀之石\"); 8 System.out.println(\"不见其损,年有所亏\"); 9 System.out.println(\"加油吧!少年\"); 10 System.out.println(\"J\"); 11 System.out.println(\"A\"); 12 System.out.println(\"V\"); 13 System.out.println(\"A\"); 14 System.out.println(\"!\"); 15 16 } 17 18 } 19 package 基础题; 20 21 public class Test2 { 22 public static void main(String[] args) { 23 // TODO Auto-generated method stub 24 int[] x = {-2147483648,-100,0,100,2147483647}; 25 double[] y= {-100.0,-10.0,0.0,10.9,100.9}; 26 for(int i=0;i<x.length;i++) { 27 System.out.println(x[i]); 28 } 29 for(int i=0;i<y.length;i++) { 30 System.out.println(y[i]); 31 } 32 } 33 } 34 package 基础题; 35 36 public class Test3 { 37 38 public static void main(String[] args) { 39 // TODO Auto-generated method stub 40 boolean[] x = {true,false}; 41 for(boolean ele : x) { 42 System.out.println(ele); 43 } 44 } 45 46 } 47 package 基础题; 48 49 public class Test4 { 50 51 public static void main(String[] args) { 52 // TODO Auto-generated method stub 53 byte x = -128; 54 byte y = 127; 55 System.out.println(x); 56 System.out.println(y); 57 short x1 = -32768; 58 short y1 = 32467; 59 System.out.println(x1); 60 System.out.println(y1); 61 int x2 = -2147483648; 62 int y2 = 2147483647; 63 long x3 = -21483649; 64 long x4 = 21483648; 65 System.out.println(x2); 66 System.out.println(y2); 67 68 69 } 70 71 } 72 package 基础题; 73 74 public class Test5 { 75 76 public static void main(String[] args) { 77 // TODO Auto-generated method stub 78 float x = -3.14f; 79 float y = 3.14f; 80 System.out.println(x); 81 System.out.println(y); 82 83 } 84 85 } 86 package 基础题; 87 88 public class Test6 { 89 90 public static void main(String[] args) { 91 // TODO Auto-generated method stub 92 char[] x = {\'9\',\'J\',\'a\',\' \',\'@\'}; 93 boolean[] y= {true,false}; 94 for(int i=0;i<x.length;i++) { 95 System.out.println(x[i]); 96 } 97 for(boolean ele : y) { 98 System.out.println(ele); 99 } 100 } 101 102 } 103 package 基础题; 104 105 public class Test7 { 106 107 public static void main(String[] args) { 108 // TODO Auto-generated method stub 109 int a =10; 110 int b =20; 111 int temp; // 交换的杯子 112 { 113 temp =a; 114 a =b; 115 b =temp; 116 } 117 System.out.println(\"a =\"+a+\", b=\"+b); 118 } 119 120 } 121 package 扩展题目; 122 123 public class Test8 { 124 125 public static void main(String[] args) { 126 // 四则运算 127 java.util.Scanner in = new java.util.Scanner(System.in); 128 System.out.println(\"请输入两个数: \"); 129 int x = in.nextInt(); 130 int y = in.nextInt(); 131 System.out.println(\"x+y= \"+ (x+y)); 132 System.out.println(\"x-y= \"+ (x-y)); 133 System.out.println(\"x*y= \"+ (x*y)); 134 if(y!=0) { 135 System.out.println(\"x/y= \"+ ((double)x/y)); 136 } 137 else { 138 System.out.println(\"在除法中分母不能为0\"); 139 } 140 } 141 142 }
来源:https://www.cnblogs.com/yuxin2021/p/15974428.html
本站部分图文来源于网络,如有侵权请联系删除。