Java Right Shift Operator
Description
The right shift operator, >>
, shifts all of the bits in a value to the right a
specified number of times.
Syntax
Its general form is shown here:
value >> num
num
specifies the number of positions to right-shift.
Example
The following code fragment shifts the value 32
to the right by two positions:
public class Main {
public static void main(String[] argv) {
//www .j ava2 s .c om
int a = 32;
a = a >> 2;
System.out.println("a is " + a);
}
}
The output: