Reverse the bytes in a short

static short reverseBytes(short i)
Returns the value obtained by reversing the order of the bytes in the two's complement representation of the specified short value.

public class Main {
  public static void main(String[] args) {
   
    System.out.println(Short.reverseBytes((short)10));
  }
}

The output:


2560
Home 
  Java Book 
    Essential Classes  

Short:
  1. Short class
  2. Find out the min value, max value and size of Short types
  3. Create Short object with its constructor
  4. Convert Short to byte, double, float, int, long and short
  5. Decode a string to short value
  6. Convert string to a short value
  7. Reverse the bytes in a short
  8. Convert short value to string
  9. Compare two short values