今天看mina原代码,看到一处用 &=、|= 的代码,一时理解不了
[code="java"] public static void main(String[] args){
int a = 1;
int b = 1;
a |= 2;
b &= ~2;
System.out.println(a);
System.out.println(b);
}[/code]
这个和+= *=是一个道理,进行与或预算
等价于
[code="java"] a = a | 2;
b = b & ~2;[/code]