與、或、非運算
//短路運算
int i=2;
int j=4;
boolean d=(i>0)||(i++>4);//短路與&&:第一個為假就為假,第二個不再進行判斷
System.out.println(d);//短路或||:第一個為真就為真,第二個不再進行判斷
System.out.println(i);
//位運算
/*
* int a=0101 0011
* int b=0100 0010
* a&b:0100 0010 位與運算,只要都為1才為1,其余都為0
* a|b:0101 0011 位或運算,只要有一個1就為1,其余均為0
* a^b:0001 0001 異或運算,只要不相同就為1,相同就為0
*~b:1011 1101 取反,0變為1,1變為0
* */
左移右移:<< >>
/*
* << n 相當於*2的n次方
* >> n 相當於/2的n次方
* 0000 0000
* 0000 0001 1
* 0000 0010 2
* 0000 0100 4
* 0000 1000 8
* */
System.out.println(4>>2); //1=4/4
System.out.println(4<<3); //32=4*8
}