Difference between right shift operator and unsigned right shift operator in Java:
all of the bits in a value to the right to a specified number of times.
int a =15;
a= a >> 3;
The above line of code moves 15 three characters right.
The places which were vacated by shift are filled with zeroes
/** * @author lautturi.com * Java example: Difference between right shift operator and unsigned right shift operator */ import java.util.*; public class Lautturi { public static void main(String[] args) { int a = -3; int b = a >> 3; int c = a >>> 3; System.out.println("a:" + a); System.out.println("b:" + b); System.out.println("c:" + c); } }
output:
a:-3 b:-1 c:536870911