数据类型扩展


public class Demo03 {
    public static void main(String[] args) {
        //整数拓展: 进制    二进制0b    八进制0    十进制    十六进制0x
        int i1 = 10;
        int i2 = 010;//八进制
        int i3 = 0x0f;//十六进制    0~9  a~f(A~F)=10~15

        System.out.println(i1);
        System.out.println(i2);
        System.out.println(i3);
        System.out.println("========================");
        //=================
        //浮点数拓展    银行业务表示
        //BigDecimal 数学工具类
        //float  有限   大约  离散  舍入误差  接近但不等于
        //double
        float f1 = 0.1f;
        double f2 = 0.1;
        System.out.println(f1);
        System.out.println(f2);
        System.out.println(f1 == f2);
        float d1 = 123434343423423423456f;
        float d2 = d1 + 1;
        System.out.println(d1 == d2);
        System.out.println("==============");
        //==============
        //字符拓展
        //==============
        char c1 = 'a';
        char c2 = '中';
        System.out.println(c1);
        System.out.println((int) c1);//强制转换
        System.out.println(c2);
        System.out.println((int) c2);
        //所有的字符本质还是数字
        //unicode 编码 2字节 0~2^16-1共计65536个
        //97 = a     65 = A
        char c3 = '\u0061';
        System.out.println(c3);
        System.out.println((int) c3);
        System.out.println("==============");
        //转义字符
        //   \t     制表符
        //   \n     换行


        System.out.println("Hello\tWorld");//
        System.out.println("==============");
        System.out.println("Hello\nWorld");

        //布尔值扩展
        System.out.println("==============");
        boolean b1 = true;
        //if (b1){    }
        //if (b1==true){        }
        //上述两行判断意义相同
        
    }
}

posted @ 2021-03-12 00:59  三散人  阅读(23)  评论(0)    收藏  举报