Java 数据类型拓展

Java 数据类型拓展

1、整数拓展

public class Deom1 {
    public static void main(String[] args) {
        //二进制0b 八进制0 十六进制0x
        int a1=10;
        int a2=010;
        int a3=0x10;
        System.out.println(a1);
        System.out.println(a2);
        System.out.println(a3);
    }
}
10
8
16

2、浮点数拓展

public class Demo2 {
    public static void main(String[] args) {
        //浮点数 有限 离散 舍入误差 接近但不等于
        //最好完全使用浮点数比较大小
        //浮点数拓展 银行业务 大数表示:BigDecimal
        float a=0.1f;//0.1
        double b=1.0/10;//0.1
        System.out.println(a==b);//a=?b
        System.out.println(a);
        System.out.println(b);
    }
}
false
0.1
0.1

3、字符拓展

public class Demo3 {
    public static void main(String[] args) {
        char c1='A';
        char c2='中';
        System.out.println(c1);
        System.out.println((int)c1);
        System.out.println(c2);
        System.out.println((int)c2);

        //所有字符的本质都是数字
        //编码 unicode 表(97=a 65=A) 2字节 0-65536

        char c3='\u0061';
        System.out.println(c3);

        //转义字符 \t 制表符  \n 换行符
        System.out.println("=========================================");

        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);
        //对象 从内存分析

    }
}

4、布尔拓展

public class Demo4 {
    public static void main(String[] args) {
        //布尔值拓展
        boolean flag=true;
        if(flag){                  //if(flag==true)
        }

    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Leon_davis

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值