单&双&单|双||的区别

   System.out.println(true|true);//true
        System.out.println(true|false);//true
        System.out.println(false|true);//true
        System.out.println(false|false);//false
        System.out.println("=============");
        System.out.println(true||true);//true
        System.out.println(true||false);//true
        System.out.println(false||true);//true
        System.out.println(false||false);//false

        System.out.println("=============");
//        不过区别在于 & 两边都运算,而 && 先算 && 左侧,
//        若左侧为 false 那么右侧就不运算了。因此从效率上来说,
//        判断语句中推荐使用 &&(换句话就是逻辑运算就老老实实用逻辑运算符,
//        不然它为啥叫逻辑运算符呢?)

        System.out.println(true&true);//true
        System.out.println(true&false);//false
        System.out.println(false&true);//false
        System.out.println(false&false);//false
        System.out.println("=============");
        System.out.println(true&&true);//true
        System.out.println(true&&false);//false
        System.out.println(false&&true);//false
        System.out.println(false&&false);//false

  

原文地址:https://www.cnblogs.com/q1359720840/p/13508451.html