how boolean values are treated in java by bit wise operators

前端 未结 4 1477
礼貌的吻别
礼貌的吻别 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

    For your case, I believe the only difference b/w & and && is the fact that for &, the second operand will still be evaluated even if the first operand evaluates to false, while in the case of && the second operand is not evaluated if the first evaluates to false.

    Mostly relevant if you have a costly method in your expression.

提交回复
热议问题