数据类型扩展及面试题详解day2

发布时间 2023-11-30 13:49:12作者: 涛dream
public class demo2 {
public static void main(String[] args) {
int a = 10;
int a1 = 010;//八进制
int a2 = 0x10;//十六进制 0~9 A~f 16

System.out.println(a1);
System.out.println(a);
System.out.println(a2);


float f = 0.1f;//0.1
double d = 1 / 10;//0.1
System.out.println(f == d);

char b1 = 'a';
char b2 = '过';

System.out.println(b1);
System.out.println((int) b1);//强制换行
System.out.println(b2);
System.out.println((int) b2);//强制换行

//所有字符本质还是数字
//编码 Unicode 表:(97 = a 65=A) 2字节 0~65536 2的16次方 =65536
// U0000 UFFFFF
char b3 = '\u2314';//Unicode对应的值
System.out.println(b3);

//转义字符
// \t 制表符
// \n 换行
//以及更多....

System.out.println("Hello \nWorld");


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);//老手
//Less is More! 代码要精简易读


}
}