How to reverse the bits in a short integer in Java



int x = i & 0x00FF;
int y = i & 0xFF00;

x = x << 8;
y = y >> 8;