>" Operator" name="description"> >" Operator" name="keywords">
In this section, you will learn how to use right shift
">>"operator in Java. The Java programming language has operators that perform bitwise operations. In the example below we have shown the usage of
right shift ">>"operator.
Description of code:
The right shift ">>"operator shifts the left operand to the right side with sign extension by the number of bits specified by its right operand. This means that a value at n place gets shifted to the right causing the n high order bits that contains the same value as that of unshifted value. This operator never throws an exception. The following example shows displays the code of right shift operator.
Here is the code of program:
Output of the program:
-24 >> 2 = -6
24 >> 2 = 6
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: March 3, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles