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
Java Book
Essential Classes
Short:
- Short class
- Find out the min value, max value and size of Short types
- Create Short object with its constructor
- Convert Short to byte, double, float, int, long and short
- Decode a string to short value
- Convert string to a short value
- Reverse the bytes in a short
- Convert short value to string
- Compare two short values