少学习多摸鱼

day 5--类型拓展

拓展

整数拓展

二进制 0b

十进制

八进制 0

十六进制 ox

 
1         int i = 10;
2         int i2 = 010;
3         int i3 = 0x10;// 0-9 A-F
4         System.out.println(i);
5         System.out.println(i2);
6         System.out.println(i3);
7         System.out.println("============================");
 

 

字符拓展

有舍入误差

float和double是不一样的

需要用到数学工具类 BigDecimal类

字符拓展

可在sout中进行强制转换

所有的字符都是数字

1         char c1 = 'a';
2         char c2 = '中';
3         System.out.println(c1);
4         System.out.println(c2);
5         System.out.println((int)c1);//强制转换
6         System.out.println((int)c2);
7         //所有的字符本质都是数字
8         char c3 = '\u0061';
9         System.out.println(c3);//a

 

转义字符

\t 制表符

\n 换行符

       
1  System.out.println("hello\tworld");
2  System.out.println("hello\nworld");

 

 
posted @ 2022-09-27 16:49  北海之上  阅读(19)  评论(0)    收藏  举报
/* 粒子吸附*/