public class Demo03 {
public static void main(String[] args) {
//整数拓展: 进制 二进制0b 十进制 八进制0 十六进制0X
int i =10; //十进制
int i2 = 010; //八进制0
int i3 = 0xb; //十六进制0X
System.out.println(i);
System.out.println(i2);
System.out.println(i3);
System.out.println("============================");
// float 有限 离散 舍入误差 大约 接近但不等于
float f = 0.1f; //0.1
double d = 1.0/10; //0.1
System.out.println(f==d);
System.out.println("============================");
float d1 = 213213213213f;
float d2 = d1+1;
System.out.println(d1==d2);
System.out.println("============================");
// 常见输出
char c1 ='A';
char c2 = '中';
System.out.println(c1); //a
System.out.println(c2); //中
System.out.println("=============底层原理===============");
System.out.println((int) c1); //97
System.out.println((int) c2); //20013
System.out.println("所有字符本质还是数字(Unicode编码)"); //20013
System.out.println("============强制转换成编码================");
char c3 = 'a';
System.out.println(c3); //正常输出
System.out.println((int) c3); //强制转换成编码输出
System.out.println("============使用编码输出================");
char c4 ='\u0061'; //Unicode编码
System.out.println(c4); // //使用编码输出
//转义字符
// \t 制表符
// \n 换行
// ......
System.out.println("Hello\nWorld");
System.out.println("============================");
String sa = new String("Hello World");
String sb = new String("Hello World");
System.out.println(sa==sb);
String sc = "Hello World";
String sd = "Hello World";
System.out.println(sc==sd);
//对象 从内存分析原理
//布尔值扩展
boolean flag = true;
if(flag==true){} //新手
if(flag){} //老手 代码要精简易读
}
}
常见输出问题
于 2024-06-01 18:00:34 首次发布