Java Integer rotateRight() MethodThe rotateRight() method of Java Integer class returns the value obtained by rotating the two's complement binary representation of the specified int value right by the specified number of bits. (Bits shifted out of the right hand, or low-order). Bit shifting is a bitwise operation which is performed on all the bits of a binary value by moving the bits to a definite number of places towards left or right. Java has a single Logical right shift operator (>>). Explanation:Syntax:Following is the declaration of rotateRight () method: Parameter:
Returns:The rotateRight () method returns the value obtained by rotating the two's complement binary representation of the specified int value right by the specified number of bits. Exceptions:NA Compatibility Version:Java 1.5 and above Example 1Output: 8 Example 2Output: Binary equivalent: 10100 Value after right rotation: 5 New Binary value after Rotated Right: 101 Example 3Output: Enter the Number: 256 Value: 64 Binary equivalent: 1000000 Value: 16 Binary equivalent: 10000 Value: 4 Binary equivalent: 100 Example 4Output: Value: -47 Value: 2147483636 Value: 536870909 Next TopicJava-integer-shortvalue-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India