• 自学习Java的第12天


    import com.sun.org.apache.xpath.internal.objects.XString;

    public class Demo03 {
    public static void main(String[] args) {
    //整数拓展 进制 二进制0b 八进制0 十进制 十六进制0x
    int i = 10;
    int i2 =010;//八进制0
    int i3 = 0x10;//十六进制0x 0-9 A-F 16
    System.out.println(i);
    System.out.println(i2);
    System.out.println(i3);
    System.out.println("===============================");
    //=============================================
    //浮点数拓展 银行业务怎么便是?钱(使用BIgDecimal)
    //===============================
    //float 有限 离散 舍入误差 大约 接近但不等于
    //最好避免使用浮点数进行比较
    //最好避免使用浮点数进行比较
    //最好避免使用浮点数进行比较
    //用BIgDecimal表示
    //double

    float f = 0.1f;//0.1
    double d = 1.0/10;//0.1
    System.out.println(f==d);//false
    System.out.println(f);
    System.out.println(d);
    float d1 = 12345678910111213f;
    float d2 = d1+1;
    System.out.println(d1==d2);//ture
    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 表:(97=a 65=A) 2字节 65536 Excel(2的16次方即65536)
    //u0000 uffff
    char c3 = 'u0061';
    System.out.println(c3);//a
    //转义字符
    // 制表符(空格)
    // 换行
    System.out.println("Hello Word");
    System.out.println("===============================");

    String sa = new String("Hello word");
    String sb = new String ("Hello word");
    System.out.println(sa==sb);
    String sc = "Hello word";
    String sd = "Hello word";
    System.out.println(sc==sd);
    //对象 从内存分析
    //布尔值扩展
    boolean flag = true;
    if (flag==true){}//新手
    if(flag){}//老手
    //Less is More! 代码要精简易读
    }
    }
  • 相关阅读:
    BZOJ 1066 [SCOI2007]蜥蜴 (最大流)
    Codeforces 1092 D2 Great Vova Wall (Version 2) (栈)
    BZOJ 1046 [HAOI2007]上升序列(LIS + 贪心)
    牛客练习赛34 D little w and Exchange(归纳)
    BZOJ 1042 [HAOI2008]硬币购物(完全背包+容斥)
    GTMD并查集!
    2018icpc南京现场赛-G Pyramid(打标找规律+逆元)
    drwxr-xr-x 2 root root 4096 06-29 14:30 Test 分段解释
    Linux里面非常重要的目录
    点击 触发 事件 的 jQuery 写法样式
  • 原文地址:https://www.cnblogs.com/leilaohu1998/p/13282152.html
Copyright © 2020-2023  润新知