Java Integer.rotateLeft(int i, int distance) example

Java Integer.rotateLeft(int i, int distance) example

By Yashwant Chavan, Views 4, Date 21-Apr-2018

In this java tutorial, You will learn how to use rotateLeft(int i, int distance) method of class Integer. This method returns Returns the value obtained by rotating the two's complement binary representation of the specified int value left by the specified number of bits.

tags Java

Returns the value obtained by rotating the two's complement binary representation of the specified int value left by the specified number of bits.

Syntax

public static int rotateLeft(int i, int distance)

Returns

The value obtained by rotating the two's complement binary representation of the specified int value left by the specified number of bits.

Java Integer rotateLeft(int i, int distance) example

  • Assign integer value.
  • Integer.rotateLeft(firstValue, 12);It will returns the value obtained by rotating left.
  • Print the values.
package com.technicalkeeda;

public class App {

    public static void main(String[] args) {

        Integer firstValue = 2;

        int result = Integer.rotateLeft(firstValue, 12);

        System.out.println("Value obtained by rotating left :- " + result);
    }
}

output

Value obtained by rotating left :- 8192
Yashwant

Yashwant

Hi there! I am founder of technicalkeeda.com and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan[at][gmail.com]