Why is order of expressions in if statement important

后端 未结 9 2059
无人共我
无人共我 2021-01-05 03:01

Suppose I have an IF condition :

if (A || B) 
    ∧
    |
    |
   left
{ 
   // do something  
}

Now suppose that A

9条回答
  •  一整个雨季
    2021-01-05 03:32

    public class Main
    {
        public static void main(String[] args) {
            System.out.println("Hello World");
            Integer a = null;
            Integer b = 3;
            Integer c = 5;
    
            if(a != null && a == 2){
                System.out.println("both");
            }else{
                System.out.println("false");
            }
        }
    }
    

    Hello World
    false

提交回复
热议问题