0
In the 11th line of the below java code,how the value of 'a' get as 3
3 Answers
+ 3
int a=1;
int b=2;
int c=3;
a|=4; // a becomes 5
b>>=1;
c<<=1; // c becomes 6
a^=c; // a(5) XOR c(6) = 3
In binary:
5: 00000101
6: 00000110
--------------------- ^ (XOR)
3: 00000011
XOR yields 1 if the first bit and second bit are different, it yields 0 if both are equal.
Hth, cmiiw
+ 1
thank you very much for the explanation it is very clear to understand....!
+ 1
You're welcome, glad if it helps : )