标签:bubuko 顺序 总结 注意 对象 技术分享 cas math inf
if (条件) { 代码块 }
if (条件) { 代码块1 } else { 代码块2 }
if (条件1) { 代码块1 } else if { 代码块2 } else { 代码块3 }
条件判断注意的事项:
        int n = 100;
        if (n >= 90){
            System.out.println("优秀");
        }else if(n >= 60){
            System.out.println("及格");
        }else{
            System.out.println("挂科");
        }        double x = 1 - 9.0 / 10;
        if (x == 0.1){
            System.out.println("x is 0.1");
        }else{
            System.out.println("x is not 0.1");
        }
        double x = 1 - 9.0 / 10;
        //修改上面的代码,改为范围比较 
        if (Math.abs(x - 0.1) < 0.00001){
            System.out.println("x is 0.1");
        }else{
            System.out.println("x is not 0.1");
        }
    }
        String s1 = "hello";
        String s2 = "HELLO".toLowerCase();
        if (s1 == s2){
            System.out.println("s1 == s2");
        }
        if (s1.equals(s2)){
            System.out.println("s1.equals(s2)");
        }
        String s3 = null;
        if (s3 != null && s3.equals("hello")){
            System.out.println("yes");
        }
标签:bubuko 顺序 总结 注意 对象 技术分享 cas math inf
原文地址:https://www.cnblogs.com/csj2018/p/10252353.html