栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

数据类型扩展

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

数据类型扩展

``整数类型扩展

public class Demo2 {
    public static void main(String [] args){
        //整数扩展 二进制0b 八进制0 十六进制0x
        int i1=10;
        int i2=0b10;
        int i3=010;
        int i4=0x10;
        System.out.println(i1);
        System.out.println(i2);
        System.out.println(i3);
        System.out.println(i4);
        System.out.println("=============================================");
        //=====================================================================
        //浮点数的扩展    是有限的,离散的,存在舍入误差
        float f = 0.1f;//0.1
        double d = 1.0/10;//0.1
        System.out.println(f==d);//false
        float d1=252525252525252.1f;
        float d2=d1+1;
        System.out.println(d2);
        System.out.println(d1==d2);//true
        //尽量避免使用浮点数进行比较
        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);//强行转换类型
        //所有的字符本质还是数字
        char c3='u0061';
        System.out.println(c3);
        //转义字符
        //制表符t
        //换行n
        System.out.println("hellonworld");
        System.out.println("hellotworld");
        System.out.println("=======================================");
        String sa = "hello world";
        String sb = "hello world";
        System.out.println(sa==sb);
        String sc=new String("hello world");
        String sd=new String("hello world");
        System.out.println(sc==sd);
    }
}

运行结果

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/343227.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号