java学习笔记002各个数值拓展

各个数值拓展

//整数拓展      进制       二进制      十进制      八进制     十六进制
int i = 10;int i2 = 010;//八进制0
int i3 = 0X10;//十六进制0x   0~9 A~F(相当于10到16)System.out.println(i);
System.out.println(i2);
System.out.println(i3);
String ccc ="------------------------------------------------------------------";
System.out.println(ccc);
//浮点数 最好完全避免使用浮点数比较
float f = 0.1f;
double d =1.0/10;
System.out.println(f==d);
System.out.println(f);
System.out.println(d);
System.out.println(ccc);//字符拓展 编码Unicode 表:97=a 2字节 0-65536
char C1 ='a';
char C2 = '中';
System.out.println(C1);
System.out.println((int)C1);//强制换行System.out.println(C2);
System.out.println((int)C2);
char c3 = '\u0062';//U0000 UFFFF
System.out.println(c3);
System.out.println(ccc);
//转义字符// \t 制表符// \n
System.out.println("hello\tworld");
System.out.println("hello\nworld");
System.out.println(ccc);
//对象 从内存分析
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! 代码要精简

 我的学习链接

 

 

 

posted @ 2021-02-10 10:42  鍠钺  阅读(122)  评论(0)    收藏  举报