Reverse bytes
In this chapter you will learn:
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) {
/* j a va2s. com*/
System.out.println(Short.reverseBytes((short)10));
}
}
The output:
Next chapter...
What you will learn in the next chapter:
- Java int type introduction
- What is octal integer and how to use it in Java
- What is hexadecimal integer and how to use it in Java
Home » Java Tutorial » Primitive Data Types