static short reverseBytes(short i)
描述 (Description)
java.lang.Short.reverseBytes()方法返回通过反转指定short值的二进制补码表示中的字节顺序而获得的值。
声明 (Declaration)
以下是java.lang.Short.reverseBytes()方法的声明
public static short reverseBytes(short i)
参数 (Parameters)
i - 这是短期价值。
返回值 (Return Value)
此方法返回通过反转指定的short值中的字节获得的值。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.Short.reverseBytes()方法的用法。
package com.iowiki;
import java.lang.*;
public class ShortDemo {
public static void main(String[] args) {
// assign value to short
short shortNum = 50;
/* returns the value after reversing the order of the bytes
in the binary representation of the specified short value. */
short shortValue = Short.reverseBytes(shortNum);
// displaying the reversed value
System.out.println("The reversed value is = " + shortValue);
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
The reversed value is = 12800