进制、浮点、字符、布尔
int i = 10;
int i2 = 010;//8进制,0开头
int i3 = 0x10;//16进制,0x开头
int i4 = 0xF;//15,10-15:A-F
System.out.println(i);//10
System.out.println(i2);//8
System.out.println(i3);//16
System.out.println(i4);//15
//浮点数拓展。银行业务怎么表示?钱
//BigDecimal 数学工具类
//=====================================
//float 有限 离散 舍入误差 大约 接近但不等于
//double
//最好完全避免使用浮点数!!!
//最好完全避免使用浮点数!!!
//最好完全避免使用浮点数!!!
float f = 0.1f;//0.1
double d = 1.0/10;//0.1
System.out.println(f == d);//false
?
float d1 =14521354521f;
float d2 = d1+1;
System.out.println(d1 == d2);//true
字符
//字符拓展?
char c1 = '中';
char c2 = 'A';
System.out.println(c1);//中
System.out.println((int)c1);//20013
?
System.out.println(c2);//A
System.out.println((int)c2);//65
//所有字符的本质还是数字
//编码 Unicode Excel 2^16 = 62236
//U0000 UFFFF
char c3 = '\u0061';
System.out.println(c3);//a
?
//转义字符
//\t 制表符(空格)
//\n换行
System.out.println("Hello\tWord");//Hello Word
System.out.println("Hello\nWord");//Hello
// Word
String sa = new String("hello word");
String sb = new String("hello word");
System.out.println(sa == sb);//false
?
String sc = "hello word";
String sd = "hello word";
System.out.println(sc == sd);//true
//对象 从内存分析
boolean
boolean flag = true;
if(flag == true){}
if(flag){}
//代码要精简精读,最好用第二个表示方法