数据拓展和转义字符

数据拓展


public class DataPlus {
    public static void main(String[] args) {
        //整数拓展: 二进制0b  十进制   八进制0  十六进制0x
        int i1 = 10;
        int i2 = 0x10;
        int i3 = 0b10;
        //System.out.println(i1);

        //小数拓展
        //银行业务怎么表示?   BigDecimal ----数学工具类
        //float 表示的数是有限的,离散的,存在有舍入误差
        //double
        //最好避免完全使用浮点数进行比较
        float f = 0.1f;
        double d = 1.0/10.0;
        //System.out.println(f == d);
        float f1 = 1232144231f;
        //float f2 = f1 + 1;
        //System.out.println(f1 == f2);//true

        //字符拓展
        char c1 = 'a';
        char c2 = '国';
        //System.out.println((int)c1);//强制转换,字符本质对应这一个数字
        //System.out.println((int)c2);
        //Unicode1个字符2个字节   U0000--UFFFF
        //System.out.println('\u0070');//

        //布尔拓展
//        boolean b = true;
//        if (b == true){};
//        if(b){};
        //这两个是一个东西,下边的默认是否判断为true
        //代码最好要精简易读
    }
}

转译字符

制表符 \t

换行符 \n

回车符 \r

posted @ 2022-09-24 09:19  北极有熊ovo  阅读(30)  评论(0)    收藏  举报