I write a program in Java to use the right shift with zero fill (>>>) operator. For the following program everything is good.
class First
{
public static void main(String[] args)
{
int b = -1;
int c = b>>>2;
System.out.println(b);
System.out.println(c);
}
}
Output is:
-1
1073741823
Everything is good in the above program. But if I write the same program for byte:
class First
{
public static void main(String[] args)
{
byte b = -1;
byte c = (byte)(b>>>2);
System.out.println(b);
System.out.println(c);
}
}
Output is:
-1
-1
It looks like working of ">>" operator rather than ">>>". My expected output was:
-1
63
Please explain the concept behind it.