数据类型的拓展

public class demo4 {
public static void main(String[] args) {
//整数拓展: 进制 二进制0b 十进制 八进制 0 十六进制0x
int b = 10;
int b1 = 010; //八进制
int b2 = 0x10; //十六进制


System.out.println(b);
System.out.println(b1);
System.out.println(b2);
System.out.println("==============================================================");
//==========================================================================================
//浮点数拓展 //舍入误差、、少去用浮点数进行比较
//float
float c = 0.8F;
double d = 8.0/10.0;
System.out.println(c);
System.out.println(d);
System.out.println(c==d);
float e = 21345543f;
float w = e+1;


System.out.println(e);
System.out.println(w);
System.out.println(e==w+1);


//字符类的拓展
char k = 'a'; //字符可以转换数字//强行转化
char x = '中';
System.out.println(k);
System.out.println((int)k);
System.out.println(x);
System.out.println((int)x);


//所有的字符本质还是数字
//编码 unicode表 a=97 占2字节 最多可以表示 65536 excel
//U0000 UFFFF

char o9 = '\u0063';




System.out.println(o9);


//转义字符
// \t 制表符 空格
// \n 换行

System.out.println("Hello\tWorld");
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){} //老手

posted @ 2021-10-28 19:33  猪肉炖粉条香香香  阅读(32)  评论(0)    收藏  举报