public class note03 {
public static void main(String[] args) {
//數據類型拓展工具
//1.整數拓展 //進制: 二進制0b 十進制 八進制0 十六進制0x int i1 = 10; int i2 = 015;//八進制 輸出爲13 int i3 = 0b101010;//二進制 輸出爲42 int i4 = 0x10f;//十六進制 輸出爲271 System.out.println(i1); System.out.println(i2); System.out.println(i3); System.out.println(i4); //2.浮點數擴展 float f = 0.1f;//0.1 double d = 1/10;//0.1 System.out.println(f==d);//輸出爲false float f1 = 2213151311131f; float f2 = f1 + 1 ; System.out.println(f1==f2);//輸出爲true //float 有限 離散 舍入偏差 大約 接近但不等於 //最好徹底使用浮點數進行比較!!! //最好徹底使用浮點數進行比較!!! //最好徹底使用浮點數進行比較!!! //銀行業務如何表示呢? //運用類 BigDecimal 數學工具類 //3.字符類拓展 char c1 = 'a'; char c2 = '中'; System.out.println(c1); System.out.println((int)c1);//輸出爲97(強制轉換) System.out.println(c2); System.out.println((int)c2);//輸出爲20013(強制轉換) //全部的字符本質爲數字 //編碼 Unicode 97=a 65=A 2字節 長度爲65536 //U0000 --- UFFFF //excel表格 最大2的16次方,爲65536 char c3 = '\u0062'; System.out.println(c3);//輸出爲b //轉義字符 \t 製表符 \n 換行 System.out.println("hello\tworld");//輸出爲hello world System.out.println("hello\nworld");//輸出爲hello // world //4.布爾值拓展 boolean flag = true; if (flag==true){} if (flag){} //二者相同 //代碼要精簡易懂 }
}編碼