Home Java Master-java Java Right Shift ">>" Operator



Java Right Shift ">>" Operator
Posted on: March 3, 2008 at 12:00 AM
In this section, you will learn how to use right shift ">>"operator in Java. The Java programming language has operators that perform bitwise operations.

Java Right Shift ">>" Operator

     

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: 

public class rightshift{
  public static void main(String[] args) {
 System.out.println(" >> opeartor");
 System.out.println(" -24 >> 2 = " +-24 >> 2));
 System.out.println("  24 >> 2 = " +(  24 >> 2));
  }
}

Output of the program:

C:\unique>javac rightshift.java

C:\unique>java rightshift
>> opeartor
-24 >> 2 = -6
24 >> 2 = 6

C:\unique>

Download this example.

Related Tags for Java Right Shift ">>" Operator:
javacprogrammingormformlanguageiooperatorsoperatorbitwisethisoperausageshowifforexamplebitprogramtolearnramexamlanshearbieilitshiftsectionusewisepeinrmoperationsasmsageminminjoperationagehowprotorrightxaxampsatratioishallmpleaarsausawisvatwssrithshoavbeloatihatpleplprmionogro


More Tutorials from this section

Ask Questions?    >"-Operator.html">Discuss: Java Right Shift ">>" Operator  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.