Java Data Type Tutorial - Java Short.reverseBytes(short i)








Syntax

Short.reverseBytes(short i) has the following syntax.

public static short reverseBytes(short i)

Example

In the following code shows how to use Short.reverseBytes(short i) method.

//from   w w w  . j a v a 2 s  . com
public class Main {

   public static void main(String[] args) {
     short shortNum = 50;

     short shortValue = Short.reverseBytes(shortNum); 
    
     System.out.println("The reversed value is = " + shortValue);
  }
}

The code above generates the following result.