public class Demo03 {
public static void main(String[] args) {
//整数拓展 进制 二进制0b开头 八进制0开头 十进制 十六进制0x开头
int a = 10;
int b = 010; //八进制0 到八进一
int c = 0x10; //十六进制0x 到十六进一
int d = 0b10; //二进制0b 到二进一
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println("====================================================");
//==============================================================
//浮点数拓展 银行业务怎么表示?算钱 不能用浮点数表示,以下有案列
//使用类 使用BigDecimal 数学工具类
//==============================================================
//float 有限 离散 舍入误差 大约 接近但不等于
//double
//最好完全避免使用浮点数进行比较
//最好完全避免使用浮点数进行比较
//最好完全避免使用浮点数进行比较
float f = 0.1f;
double g = 1.0/10;
System.out.println(f==g);//false 是错的 两者不一样但是正常输出都是0.1
System.out.println(f);
System.out.println(g);
float f1 = 23232323f;
float f2 = f1 + 1;
System.out.println(f1 == f2);//true 是对的
//=============================================
//字符拓展
//=============================================
char c1 = 'a';
char c2 = '中';
System.out.println(c1);
System.out.println((int)c1);//强制转换
System.out.println(c2);
System.out.println((int)c2);//强制转换
//所有的字符本质还是数字 char可以被int强制转换 内含Unicode编码
//编码 Unicode 内含一个表 a=97 A=65 2字节 0-65536 Excel 2 的16次方 = 65536
// U0000 UFFFF
char c3 = '\u0061'; //输出为a 内含Unicode编码 表
System.out.println(c3); //a
//转义字符
// \t 空格 制表符
// \n 换行 等有很多
System.out.println("Hello\tWorld");
//===================================
String d1 = new String("hello world");
String d2 = new String("hello world");
System.out.println(d1==d2);//flase 错的
System.out.println("===================================");
String d3 = "hello world";
String d4 = "hello world";
System.out.println(d3 == d4);//true 对的
// 对象 从内存分析
// ======================================
//布尔值拓展
boolean flag = true;
if (flag == true);{}
if (flag);{}
//以上两个代码是一样的
}
}