zoukankan      html  css  js  c++  java
  • 单&双&单|双||的区别

       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
    

      

  • 相关阅读:
    计算机是如何启动的
    比特币
    区块链技术
    哈夫曼树与哈夫曼编码
    Prim Algoritm(最小生成树)
    机器学习概述总览
    线性查找算法(BFPRT)
    DFS(深度优先搜索)
    BFS(广度优先搜索)
    (Dijkstra)迪杰斯特拉算法-最短路径算法
  • 原文地址:https://www.cnblogs.com/q1359720840/p/13508451.html
Copyright © 2011-2022 走看看