Java Data Type Tutorial - Java Long.reverseBytes(long i)








Syntax

Long.reverseBytes(long i) has the following syntax.

public static long reverseBytes(long i)

Example

In the following code shows how to use Long.reverseBytes(long i) method.

public class Main {
/*from ww w  .  j av  a 2  s . c  om*/
   public static void main(String[] args) {

     long l = 8;
     System.out.println("Number = " + l);
    
     System.out.println("Binary = " + Long.toBinaryString(l));

     System.out.println("After reversing = " + Long.reverseBytes(l));
   }
}

The code above generates the following result.