Refer to https://github.com/wangbingfeng/OnJava8-Examples/blob/master/operators/URShift.java modification
// operators/URShift.java
// (c)2017 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
// Test of unsigned right shift
public class URShift {
public static void main(String[] args) {
int i = -1;
System.out.println(Integer.toBinaryString(i));
System.out.println((Integer.toBinaryString(i).length()));
i >>>= 10;
System.out.println(Integer.toBinaryString(i));
System.out.println((Integer.toBinaryString(i).length()));
System.out.println("i >>>=10 :" + i);
long l = -1;
System.out.println(Long.toBinaryString(l));
System.out.println((Long.toBinaryString(l).length()));
l >>>= 10;
System.out.println(Long.toBinaryString(l));
System.out.println((Long.toBinaryString(l).length()));
short s = -1;
System.out.println(Integer.toBinaryString(s));
s >>>= 10;
System.out.println(Integer.toBinaryString(s));
byte b = -1;
System.out.println(Integer.toBinaryString(b));
b >>>= 10;
System.out.println(Integer.toBinaryString(b));
b = -1;
System.out.println(Integer.toBinaryString(b));
System.out.println(Integer.toBinaryString(b >>> 10));
int[] iarray = new int[5];
System.out.println(iarray.length);
}
}
/* output:
11111111111111111111111111111111
32
1111111111111111111111
22
i >>>=10 :4194303
1111111111111111111111111111111111111111111111111111111111111111
64
111111111111111111111111111111111111111111111111111111
54
11111111111111111111111111111111
11111111111111111111111111111111
11111111111111111111111111111111
11111111111111111111111111111111
11111111111111111111111111111111
1111111111111111111111
5
*/