Shift Operator Example: >> vs >>> in Java

Java Programming Language / Operators in java

1526

Program:

 class OperatorExample{  
public static void main(String args[])
   {  
    //For positive number, >> and >>> works same  
    System.out.println(20>>2);  
    System.out.println(20>>>2);  
    //For nagative number, >>> changes parity bit (MSB) to 0  
    System.out.println(-20>>2);  
    System.out.println(-20>>>2);  
   }
}  

Output:

5
5
-5
1073741819
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.