Reverse the bytes in a short

ReturnMethodSummary
static shortreverseBytes(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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.