English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Integer.rotateLeft() method returns the value obtained by rotating the binary complement binary representation of the specified integer value i to the left by the specified number of bits. The following is the syntax.
int rotateLeft(int i, int distance)
This is the parameter.
i-This is the int value.
distance-This is the rotation distance.
public class Demo { public static void main(String[] args) { int val = 1; for (int i = 0; i < 4; i++) { val = Integer.rotateLeft(val, 1); System.out.println(val); } } }
Output Result
2 4 8 16