青草味的懒羊羊  
整数扩展
  • 二进制(0b开头)

  • 十进制

  • 八进制(0开头)

  • 十六进制(0x开头) 0-9 A-F(F:16)

int i=10;//十进制
int i2=010;//八进制0
int i3=0x10;//十六进制0x  0-9 A-F(F:16)
System.out.println("十进制"+i); //10
System.out.println("八进制"+i2);//8
System.out.println("十六进制"+i3);//16
浮点扩展
  • BigDecimal类型可用于浮点类型的比较计算,float 有限 离散 舍入误差 大约 接近但不等于
字符扩展
  • 所有字符型本质都是数字
  • 编码 Unicode表: (97 = a 65 = A) 2字节 0-65535 2的16次幂=65535
char c1='A';
char c2='中';
System.out.println(c1);
System.out.println((int)c1);//强制转换字符型可得到对应的Unicode数字编码
System.out.println(c2);
System.out.println((int)c2);//强制转换字符型可得到对应的Unicode数字编码
  • Unicode编码的转义表示 U0000 - UFFFF(区间范围)
char c3='\u0061';
System.out.println(c3); //a
转义字符
// \t制表符
// \n回车
// \r换行
// \f换页
// \'单引号
// \"双引号
// \\反斜杠
// \b推格
// \d八进制
// \xd十六进制
// \ud Unicode字符
System.out.println("Hello\tWorld");
对象,从内存分析
String sa=new String("hello world");
String sb=new String("hello word");
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){}
//less is more 代码要精简易读
posted on 2021-09-04 23:15  青草味的懒羊羊  阅读(28)  评论(0编辑  收藏  举报