how boolean values are treated in java by bit wise operators

前端 未结 4 1267
礼貌的吻别
礼貌的吻别 2021-01-14 19:48

consider this example please

int i=11, j=5;
boolean b=true, c=false;
System.out.println(b&c); // --> output=false
System.out.println(i&j); // --&g         


        
4条回答
  •  时光说笑
    2021-01-14 20:37

    The first operation you do - TRUE & FALSE is taken as 1 & 0, which is false.

    The second operation - 11 & 5 is taken as 1011 & 0101 (the binary values), which is 0001 when anded.

提交回复
热议问题