数据类型扩展

数据类型扩展及面试题讲解

//整数拓展: 进制 二进制0b 八进制 十进制0 十六进制0x
int i=10;
int i2=010;
int i3=0x10;
System.out.println(i);
System.out.println(i2);
System.out.println(i3);
System.out.println("浮点拓展? 银行业务怎么表示钱");
//浮点拓展? 银行业务怎么表示钱
//BigDecimal 数学工具类---用来对超过16位有效位的数进行精确的运算。

//双精度浮点型变量double可以处理16位有效数。在实际应用中,需要对更大或者更小的数进行运算和处理
//float 有限 离散 舍入错误 大约 接近不相等
//double
System.out.println("最好完全使用浮点书进行比较");
float a=0.1f;
double b=1.0/10;
System.out.println(a==b);//false
float a1=123322222;
float a2= a1 + 1;
System.out.println(a1==a2);//true
System.out.println("字符拓展==========");
char c1='a';
char c2='中';
System.out.println(c1);
System.out.println(c2);
System.out.println("强制转换int类型,所以的字符串本质都是数字");
System.out.println((int) c1);
System.out.println((int) c2);
char c3='\u0061';
System.out.println(c3);
System.out.println("转义字符=========");
//System.out.println("hello\nword");
String sa= new String("helloword");
String sb= new String("helloword");
System.out.println(sa==sb);//false
System.out.println("为什么不相等呢,因为这是两个对象的比较,从内存分析");
System.out.println("布尔值扩展=======");
boolean flag=true;
if (flag==true){
System.out.println("我是flag");
}
if (flag){
System.out.println("我是flag");
}

posted @ 2022-08-06 21:12  菜鸡前来  阅读(23)  评论(0编辑  收藏  举报