整数拓展: 进制
二进制(0b开头)
十进制
八进制(0开头)
十六进制(0x开头)
int y=20; int y2=020; int y3=0x20;
浮点拓展:
float
double
float g=0.1f; //等于0.1 double f=2.0/20; //等于0.1 System.out.println(g==f); //false(非) float u1=127838823937890f; float u2=u1+1; System.out.println(u1==u2); //true(是)
字符拓展:
char w1='e'; char w2='哈'; System.out.println(w1);//等于e System.out.println((int)w1);//等于101 //强制转换 System.out.println(w2);//等于哈 System.out.println((int)w2);//等于21704 //强制转换
所有字符本质还是数字
- 编码 Unicode 表:(101=e 69=E)二字节
U0000 UFFFF
char w3='u0071'; System.out.print(w3); //等于q
转义字符
t 制表符
n 换行
System.out.println("HellotWorld");
System.out.pritnln("HellonWorld");
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.pritnln(sc==sd);// true
布尔值拓展
boolean flag=true;
if(flag==true){} //新手
if(flag){} //老手
代码要精简易读



