2011年12月23日星期五

第5天第4节: Java基本运算操作

==Logical operation
&  : and, all the condition must tested
&&: and, if the first is false, the rest is not tested

| : or, all the condition must tested
|| : or, if the first is true, the rest is not tested.

        int x = 3;
        if(true | x++>1) {
            System.out.println(x);   ==> 4
        }
       
        x = 3;
        if(true || x++>1) {
            System.out.println(x);  ==> 3
        }   

==Bit operation
|
&
>>
<<
>>>  no-sign
Negative number: 2's complement 正数反码加1

没有评论: