Mega Code Archive

 
Categories / Java Book / 001 Language Basics
 

0033 The Right Shift

>, shifts all of the bits in a value to the right a specified number of times. Its general form is shown here: ]]> value >> num num specifies the number of positions to right-shift. The following code fragment shifts the value 32 to the right by two positions: public class Main { public static void main(String[] argv) { int a = 32; a = a >> 2; System.out.println("a is " + a); } } The output: a is 8