java.lang.Integer.rotateLeft()%uA0方法返回通过旋转指定int i值左移位的指定数的二进制补码表示法得到的值。 (位移出左侧或高阶,侧重新输入在右边,或低位)。
声明
以下是java.lang.Integer.rotateLeft()方法的声明
public static int rotateLeft(int i, int distance)
参数
-
i%uA0-- 这是int值。
-
distance%uA0-- 这是旋转的距离。
返回值
此方法返回通过旋转由位的指定数左移指定的int值的二进制补码表示法得到的值。
异常
-
NA
例子
下面的例子显示java.lang.Integer.rotateLeft()方法的使用。
package com.yiibai import java.lang.* public class IntegerDemo { public static void main(String[] args) { int n = 2 // returns the value obtained by rotating left for(int i = 0 i < 4 i++) { n = Integer.rotateLeft(n, 4) System.out.println(n) } } }
让我们来编译和运行上面的程序,这将产生以下结果:
32 512 8192 131072