public class Demo03 {
public static void main(String[] args) {
//整数拓展:进制、二进制(0b开头)、八进制(0开头)、十进制、十六进制(0x开头)
int n = 10;
int n1 = 010; //8进制0开头
/*16进制 0x开头0~9 A~F 16*/
int n2 = 0x10; //16进制0x开头 0~9 A~F 16
System.out.println(n);
System.out.println(n1);
System.out.println(n2);
System.out.println("=========================================================================================");
/*
* ======================================================================================================================
* */
//浮点数(小数)拓展:银行业务怎么表示?钱
//flaot
//double
float f = 0.1f;
double d = 0.1;
/*false*/
System.out.println(f==d);
System.out.println(f);
System.out.println(d);
float d1 = 893839393933f;
float d2 = d1 + 1;
/*true*/
System.out.println(d1==d2);
//为何不等的两个浮点数操作后却相等==?
//因为float浮点数所表示的字长是有限的也是离散的
//会舍入误差,很多数据没办法精确表示
//结果只能是大约数,接近但不等于
/*重点*/
//最好完全避免使用浮点数float进行比较
/**
*字符串拓展
**/
System.out.println("========================================================================================");
char c = 'a';
char c1 = '缤';
System.out.println(c);
System.out.println((int)c);//强制转换
System.out.println(c1);
System.out.println((int)c1);//强制转换
//强制转换可以把字符变成数字
/*是所有的字符本质还是数字,所以在此情况下可以强制转换*/
/**Unicode编码占2字节(byte),最多可表示65536个字符即2的16次方,即Excel表格原始长度*/
/**Unicode有个对应编码表,如97=a,65=A*/
/**涉及相关unicode代码表中的字符都可以进行强制转换*/
/**区间在U0000-UFFFF*/
/**Unicode编码规范指定标准*/
//把世界上所有能出现的字符,都为其分配一个数字来表示,比如,数字U+7F57被分配给了汉字中的"罗"字。Unicode编码的标准里字符数量一直实在
//新增(包括一些稀有字符,当然emoji表情字符也属于unicode编码哈哈),19年3月刚发布了Unicode12.0版本,比之前的版本新增了一些字符
//现在在标准中的字符一共有137929个,而Unicode编码目前规划了U+0000至U+10FFFF为unicode编码(以世界上字符的数量应该是很久不会考虑
//扩展的),算一下目前还剩下976183(1114112-137929)个代码点,这976183个代码点是规划在unicode中的数字,但是还没被分配对应的字符。
/*https://www.cnblogs.com/hahlzj/p/11908713.html*/
System.out.println("----------------------------------------------------------------------------------------");
//-------------------------------------------------------------------------------------------------------------
/**unicode转义输出*/
/**unicode代码区间U0000-UFFFF*/
char c3 = '\u0061';//转义字符
System.out.println(c3);
char c4 = '\uFFFF';//转义字符
System.out.println(c4);
/*转义字符*/
// \t制表符(空格)
System.out.println("Hey\t2opz");
// \n换行
System.out.println("Hey\n2opz");
/**拓展链接
* https://baike.baidu.com/item/%E8%BD%AC%E4%B9%89%E5%AD%97%E7%AC%A6/86397?fr=aladdin
* 常用转义字符 https://www.cnblogs.com/EasonJim/p/6561576.html
* */
System.out.println("-----------------------------------------------------------------------------------------");
/*String拓展*/
/**同等赋值条件下,za!=zb*/
//sout执行结果为false
String za = new String("Hey\t2opz");
String zb = new String("Hey\t2opz");
System.out.println(za==zb);
/**语句不同情况下,za==zb*/
//sout执行结果为true
//(关系到对象与内存分析)
String xa = "Hey\t2opz";
String xb = "Hey\t2opz";
System.out.println(xa==xb);
/**布尔值拓展*/
boolean example = true;
/**if(example==true){sout语句} == if(example){}*/
/*新手写法*/
if (example==true){
System.out.println("I just wanna B Ur Dad");
}
/*老手程序员,less is more*/
if (example){
System.out.println("NO WAY SIR");
}
}
}
运行结果依次附上: