• Java关键字学习 持续完善中


    Java关键字学习

    访问权限修饰关键字

    关键字 同一个类 同包 不同包,子类 不同包,非子类
    public
    private
    protected
    default

    八大基本数据类型

    关键字 取值范围 举例
    byte 字节型 1 byte 8位 (-2^7 ~ 2^7-1) byte n = 6;
    short 短整型 2 byte 16位 (-2^15 ~ 2^15-1) short n = 6666;
    int 整形 4 byte 32位 (-2^31 ~ -2^31-1) int n = 66666666;
    long 长整型 8 byte 64位 (-2^64 ~ 2^64-1) long n = 66666666666666L;
    float 单精度 4 byte 32位 (1.17549435e-38f ~ 3.4028235e+38f) float f = 1.123f;
    double 双精度 8 byte 64位 (4.9e-324 ~ 1.7976931348623157e+308) double d = 3.1415926535897932d;
    char 字符型 2 byte 16位 (0 ~ 2^16-1) char a = 'a';
    boolean boolean为布尔基本类型 true/false boolean b = false;

    扩展

    //进制拓展
    int i = 10;     //十进制  
    int i2 = 010;   //八进制       0开头
    int i3 = 0x10;  //十六进制      0x开头   0~9 a~f 
    int i4 = 0x11;
    System.out.println(i);  //10
    System.out.println(i2); //8
    System.out.println(i3); //16
    System.out.println(i4); //17
    
    System.out.println("==================华丽丽的分割线===============");
    //浮点数拓展   银行业务
    //float 有限   离散   舍入误差   大约  接近但不等于
    //double  
    //最好完全避免用浮点数比较
    float f = 0.1f;
    double d = 1.0/10;  
    System.out.println(f);  //0.1
    System.out.println(d);  //0.1
    System.out.println(f==d); //false
    
    float d1 = 23232323232323f;
    float d2 = d1 + 1;
    System.out.println(d1==d2); //true
    
    BigDecimal bigDecimal = new BigDecimal(0.1);
    
    System.out.println("==================华丽丽的分割线===============");
    //字符拓展
    //所有的字符本质还是数字  unicode编码  65536个字符 Excel表格2^16 (65536)  U0000~UFFFF
    char c1 = 'a';
    char c2 = '中';
    System.out.println(c1); //a
    System.out.println((int)c1); //97
    System.out.println(c2); //中
    System.out.println((int)c2); //20013
    
    char c3 = 'u0061';
    System.out.println(c3); //a
    
    //转义字符   	 制表符  
    换行
    System.out.println("Hello	World!");    //Hello World!
    System.out.println("Hello
    World!");    //Hello
    										//World!
    
    String s1 = new String("Hello World!");
    String s2 = new String("Hello World!");
    System.out.println(s1 == s2);   //false
    
    String s3 = "Hello World!";
    String s4 = "Hello World!";
    System.out.println(s3 == s4);   //true
    System.out.println("==================华丽丽的分割线===============");
    //布尔值拓展
    boolean flag = true;
    if(flag == true){   
    
    }
    if(flag){
        //less is more  代码要精简易读
    }
    
  • 相关阅读:
    ajax(ajax开发)
    gnuplot常用技巧
    Gunplot 命令大全
    程序员的绘图利器 — Gnuplot
    什么是 gnuplot
    QT正则表达式---针对IP地址
    JSP实现分页功能
    java.lang.OutOfMemoryError: Java heap space错误及处理办法
    getInitParameter()
    C/S软件的自动升级部署
  • 原文地址:https://www.cnblogs.com/bky-min/p/12843454.html
Copyright © 2020-2023  润新知