
Introduction to Operators and Expression in Java • 67
/* PROG 3.20 DEMO OF RIGHT SHIFT WITH ZERO FILL (>>>)OPERATOR */
class JPS20
{
public static void main(String args[])
{
int x = -1;
int y1 = x >>> 16;
int y2 = x >> 16;
System.out.print(“\n\nApplying >> on -1,16 times”);
System.out.println(“ give “ + y2);
System.out.print(“\nApplying >>> on -1,16 times”);
System.out.println(“ give “ + y1);
}
}
OUTPUT:
Applying >> on -1, 16 times give -1
Applying >>> on -1, 16 times give 65535
Explanation: Internally, −1 is represented as all ones. In 32 bit format, it can be shown as follows:
32-bit format