Java(2022.511)
int 1 = 10;
int i2 = 010; //八进制 0 以0开始
int i3 = 0x10; //十六进制0x 0-9 A-F
例如上面三类输出后得到的数据为:
System.out.println(i1); //10
System.out.println(i2); //8
System.out.println(i3); //16
浮点数拓展
BigDecimal 数学工具类
//float 有限 离散 舍入误差 大约 接近但不等于
//double
//最好完全使用浮点数进行比较
float f = 0.1f;
double d = 1.0/10;
System.out.println(f==d);
System.out.println(f);
System.out.println(d);
以上结果分别为
false
0.1
0.1
float d1 = 2345156454156f;
float d2 = 1 + d1;
System.out.println(d1==d2);
该结果为:true
字符拓展
char c1 = 'a';
char c2 = '中';
System.out.println(c1);
System.out.println((int)c1); //强制转换
System.out.println(c2);
System.out.println((int)c2); //强制转换
上面结果分别为
a
97
中
20013
//所有的字符本质都是数字
char c3 = '\u0061';
System.out.println(c3); //该结果为a
转义字符
// \t 制字符(类似于空格隔开)
// \n 换行
System.out.println("Hello\tWorld");
该结果为——Hello World
System.out.println("Hello\nWorld");
该结果为—— Hello
World
String sa = new String(original:"hello,world");
String sb = new String(original:"hello,world");
System.out.println(sa==sb);
String sc = "hello,world";
String sd = "hello,world";
System.out.println(sc==sd);
以上结果为:
false
true
//对象 从内分析
布尔值拓展
boolean flag = true;
if (flag==true){} //新手
if(flag){} //老手
//Less is More! 代码要简洁易读
浙公网安备 33010602011771号