public class demo1 {
public static void main(String[] args) {
//银行业务怎么做 ? 钱 拓展
//float 有限 离散 舍入误差 大约 接近但不等于
//BigDecimal 数学工具类
//最好完全避免使用浮点数进行比较
float f=0.1F;
double d=1.0/10;
System.out.println(f==d);//false
System.out.println(f);
System.out.println(d);
float f1=2121121211122F;
float f2=f1 +1;
System.out.println(f1==f2);//true
System.out.println("......................................");
//字符拓展
//所有字符本质还是数字
char c1='a';
char c2='中';
System.out.println(c1);
System.out.println((int)c1);
System.out.println(c2);
System.out.println((int)c2);
//编码 Unicade 表 (97=a 65=A) 2字节
//U0000 ~ UFFFF
char c3 = '\u0061';//16进制 转义
System.out.println(c3);
System.out.println(".......................................");
//转义字符
// \t 制表符
// \n 换行
//...
System.out.println("hello\twor\nld");
System.out.println("..............................");
String s1 = new String("hello world");
String s2 = new String("hello world");
System.out.println(s1==s2);
String s3 = "hello world";
String s4 = "hello world";
System.out.println(s3==s4);
//对象 从内存分析
//布尔值扩展
boolean flag = true;
if (flag == true);//新手
if (flag);//老手
//less is more! 代码要精简易读
}
}
基础02基础拓展
于 2022-11-09 18:43:19 首次发布