```
// you need treat n as an unsigned value
public int reverseBits(int n) {
for (int i = 0; i < 16; i++) {
// two symmetric bits for comparison
int j = 31 - i;
// two digits are different, swap them
if (((n >> i ^ n >> j) & 1) == 1) {
n = n ^ 1 << i;
n = n ^ 1 << j;
}
}
return n;
}
```