Integer.reverseBytes() method in Java


The method returns the value obtained by reversing the order of the bytes in the two's complement representation of the specified int value. Let us now see the syntax.

int reverseBytes(int i)

The following is the parameter.

  • i − This is the int value

Example

 Live Demo

public class Demo {
   public static void main(String []args) {
      System.out.println(Integer.reverseBytes(0));
      System.out.println(Integer.reverseBytes(-87));
      System.out.println(Integer.reverseBytes(98));
   }
}

Output

0
-1442840577
1644167168

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 26-Jun-2020

53 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements