This comes up after solve the problem:
My solution is:
static long flippingBits(long n) {
long l=0; //Have to pre-declare 0, Why?
return (~l>>>32)&~n;
}
But what I wanted to do is use the 0 direct into the return statement instead of declaring it before in "long l", like this:
static long flippingBits(long n) {
return (~0>>>32)&~n; //Using 0 directly don't works.
}
I also tried with parenthesis but is the same. After testing looks like it is not able to shift if I put the 0 directly.
Why is giving me a different value?