public static int reverseBits(int n) {
    for (int i = 0; i < 16; i++) {
      int j = 31 - i;
      int a = n & (1 << i);
      int b = n & (1 << j);
      if ((0 == a && 0 == b) || (0 != a && 0 != b)) continue;
      n = n ^ (1 << i);
      n = n ^ (1 << j);
    }
      return n;        
  }