89
Java Integer reverseBytes (int i) Method
The reverseBytes() method of Java Integer class numerically returns the value obtained by reversing the order of the bytes in the 2’s complement binary representation of the specified integer value.
Syntax:
Following is the declaration of reverseBytes() method:
Parameter:
DataType | Parameter | Description | Required/Optional |
---|---|---|---|
int | i | Integer value whose bytes are to be reversed. | Required |
Returns:
The reverseBytes() method returns the numeric value obtained by reversing order of the bytes in the specified int value.
Exceptions:
NA
Compatibility Version:
Java 1.5 and above
Example 1
Output:
Number = 202 After reversing = -905969664
Example 2
Output:
Enter Integer Value: 208 Number = 208 Binary Representation = 11010000 After reversing = -805306368
Example 3
Output:
Number = 202 Binary Representation = 11001010 After reversing = -905969664 Number = -50 Binary Representation = 11111111111111111111111111001110 After reversing = -822083585
Example 4
Output:
Enter Number from console: 850 Result: 5909567136040222720
Next TopicrotateLeft() Method