數據類型2
public class Demo03 {
public static void main(String[] args){
//整數拓展: 進制 二進制0b 十進制 八進制0 十六進制0x
int i=10; //十進制
int i2=010; //八進制0
int i3=0x10; //十六進制0x
int i4=0b10; //二進制0b
System.out.println(i);
System.out.println(i2);
System.out.println(i3);
System.out.println(i4);
System.out.println("=========================");
//==================================
//浮點數拓展? 銀行業務怎么表示?錢
//==================================
//float
//double
/*float f=0.1; //0.1
double d=1.0/10; //0.1
System.out.println(f==d);
System.out.println(f);
System.out.println(d);*/
float d1=232232323122315456618789878f;
float d2=d1+1;
System.out.println(d1==d2);//trus
//==================================
//字符拓展?
//==================================
System.out.println("=========================");
char c1='a';
char c2='中';
System.out.println(c1);
System.out.println((int)c1);//強行轉換
System.out.println(c2);
System.out.println((int)c2);//強行轉換
//所有的字符本質還是數字
//編碼 Unicode 表:97=a 2字節 0 - 65536 Excel 2 16=65536
//U0000 UFFFF
char c3='\u0061';
System.out.println(c3); //a
//轉義字符
// \t 制表符
// \n 換行
// \a 響鈴
// \b 退格
// \f 換頁
// \r 回車
// \v 垂直制表
System.out.println("Holle\tWorld");
System.out.println("Hello\nWorld");
System.out.println("=========================");
//對象 從內存分析
String sa = new String("hello world");
String sb = new String("hello world");
System.out.println(sa==sb);//false
String sc ="hello world";
String sd ="hello world";
System.out.println(sc==sd);//true
//布爾值拓展
boolean flag = true;
if (flag==true){} //新手
if (flag){} //老手
//Less is More! 代碼要精簡易讀
}
}


浙公網安備 33010602011771號