Short reverseBytes() in Java with Examples Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The reverseBytes() method of Short class is a built in method in Java which is used to return the value obtained by reversing the order of the bytes in the two's complement representation of the specified short value. Syntax : public static short reverseBytes(short a) Parameter: The method takes one parameter a of short type whose bytes are to be reversed. Return Value: The method will return the value obtained by reversing the bytes in the specified short value. Examples: Input: 75 Output: 1258291200 Explanation: Consider an short a = 75 Binary Representation = 1001011 Number of one bit = 4 After reversing the bytes = 1258291200 Input: -43 Output: -704643073 Below programs illustrate the Short.reverseBytes() method: Program 1: For a positive number. java // Java program to illustrate the // Short.reverseBytes() method import java.lang.*; public class Geeks { public static void main(String[] args) { // Create a Short instance short a = 61; // Print the value before reversal of Bytes System.out.println("Original value = " + a); // Reverse the bytes in the specified short value // Using reverseBytes() method System.out.println("After reversing the bytes : \n" + "New value : " + Short.reverseBytes(a)); } } Output: Original value = 61 After reversing the bytes : New value : 15616 Program 2: For a negative number. java // Java program to illustrate the // Short.reverseBytes() method import java.lang.*; public class Geeks { public static void main(String[] args) { // Create a Short instance short a = -45; // Print the value before reversal of Bytes System.out.println("Original value = " + a); // Reverse the bytes in the specified short value // Using reverseBytes() method System.out.println("After reversing the bytes : \n" + "New value : " + Short.reverseBytes(a)); } } Output: Original value = -45 After reversing the bytes : New value : -11265 Comment More infoAdvertise with us S Sruti Rai Follow Improve Article Tags : Misc Java java-basics Java-lang package Java-Functions Java-Short +2 More Practice Tags : JavaMisc Explore BasicsIntroduction to Java4 min readJava Programming Basics9 min readJava Methods7 min readAccess Modifiers in Java6 min readArrays in Java9 min readJava Strings8 min readRegular Expressions in Java7 min readOOPs & InterfacesClasses and Objects in Java10 min readJava Constructors10 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface11 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java6 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling8 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial15+ min readSynchronization in Java10 min readFile Handling in Java5 min readJava Method References9 min readJava 8 Stream Tutorial15+ min readJava Networking15+ min readJDBC Tutorial12 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples8 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions7 min readJava Quiz | Level Up Your Java Skills1 min readTop 50 Java Project Ideas For Beginners and Advanced [Update 2025]15+ min read Like