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 {
//  w  w  w  . j  a v a  2s.c o  m
   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.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable