标签:
1 /** 2 * 类的说明 3 * 4 * @author hasee作者 5 * 6 */ 7 public class hello { 8 /** 9 * 这是主方法,是程序的入口 10 * 11 * @param args输入参数,字符串类型的数组 12 */ 13 public static void main(String[] args) { 14 // 关键代码 15 // 注释 16 17 System.out.println("Hello World"); 18 19 String _$dd123 = "";// 定义变量 20 21 int i; 22 23 i = 123; 24 25 int m = 1, n = 2, x = 4, y = 5; 26 27 final double PAI = 3.14; 28 29 // pai = 3.1415926; 30 31 // i = "ddd" 32 33 String strUserName = "tom住在这个房间"; 34 35 System.out.println(strUserName); 36 37 strUserName = "张三住在这里"; 38 39 System.out.println(strUserName); 40 41 byte b = -128; 42 43 short s = 2; 44 45 int j = 123; 46 47 int l = (int) 1234L;// 强制转换,显示转换 48 49 long ll = b; 50 51 float f = 123.45F; 52 53 double d = 123.45D; 54 55 f = (float) d; 56 57 char c = ‘a‘; 58 59 int a = c; 60 61 System.out.println("a =" + a); 62 63 char g = 98; 64 65 System.out.println("g =" + g); // ASCII码 66 67 // UTF-8 68 69 boolean t = true;// 1表示true,逻辑真 70 71 t = false;// 0表示false,逻辑假 72 73 System.out.println("20 % 7 = " + (20 % 7)); 74 75 int z = 10; 76 77 // z++; //z = z + 1 78 79 System.out.println("z = " + z++); 80 81 // z--; //z = z - 1 82 83 System.out.println("z = " + z--); 84 85 System.out.println("z = " + z); 86 87 // System.out.println("z = " + ++z); 88 89 // z--; //z = z - 1 90 91 // System.out.println("z = " + --z); 92 93 // System.out.println("z = " + z); 94 95 z = 10; 96 97 int k = ++z; 98 99 z += 2;// z = z+2; 100 z -= 2;// z = z-2; 101 102 z *= 2;// z = z *2; 103 z /= 2;// z = z /2; 104 z %= 2;// z = z %2; 105 106 boolean luoji = true & true; 107 System.out.println("true && true = " + luoji); 108 109 luoji = true && false; 110 System.out.println("true && false = " + luoji); 111 112 luoji = false && false; 113 System.out.println("false && false = " + luoji); 114 115 luoji = (2 > 1 & 3 < 4); 116 117 luoji = true || true; 118 System.out.println("true || true = " + luoji); 119 120 luoji = true || false; 121 System.out.println("true || false = " + luoji); 122 123 luoji = false || false; 124 System.out.println("false || false = " + luoji); 125 126 luoji = !(2 > 1 || 3 > 4);// 本来结果为true,前面加了!结果就反转了成了false 127 128 int v = 2 > 1 ? 1 : 2; 129 130 String str = 4 > 5 ? "asd" : ""; 131 132 String ss = ""; 133 134 if (4 > 5) { 135 ss = "asd"; 136 } 137 138 int q = ((2 + 1) * (4 - 3)); 139 140 System.out.println("10 != 9 = " + (10 == 9)); 141 142 String a2 = ""; 143 144 } 145 }
标签:
原文地址:http://www.cnblogs.com/sihuiming/p/5011158.html