zoukankan      html  css  js  c++  java
  • java运算符之位运算

    package operator;
    
    public class Demo03 {
        public static void main(String[] args) {
            text();
    
            text2();
    
            text3();
        }
    
        public  static void  text3(){
            //位运算
            /*
            A = 0011 1100
            B = 0000 1101
    
            A&B(A与B) =0000 1100
            A|B(A或B) =0011 1101
            A^B(异或) =0011 0001 相同为0 不同为1
            ~B(取反) =1111 0010
    
            2*8=16
    
            <<(左移)  *2
            >>(右移)  /2
    
            0000 0000   0
            0000 0001   1
            0000 0010   2
            0000 0011   3
            0000 0100   4
            0000 1000   8
            0001 0000   16
    
    
            * */
    
            System.out.println("2<<3:==》"+(2<<3));
        }
    
        public  static  void  text(){
            //短路运算
             int a=5;
             boolean b=(a<4)&&(a++<4);
            System.out.println(a);//5
            System.out.println(b);//false
        }
    
        public  static  void  text2(){
            boolean a=true;
            boolean b=false;
    
            System.out.println("a && b:	"+(a&&b));//false
            System.out.println("a || b:	"+(a||b));//true
            System.out.println("!a && b:	"+!(a&&b));//true
    
        }
    }
    
    
  • 相关阅读:
    10.31JS日记
    10.24JS日记
    10.23JS日记
    10.22JS日记
    10.19JS日记
    10.18JS日记
    Tomcat—Bad Request
    2016年上半年总结
    线程间操作无效
    压缩字符串的函数
  • 原文地址:https://www.cnblogs.com/d534/p/15070113.html
Copyright © 2011-2022 走看看