Differences


1.Difference between >> and >>>:

The >> is signed right shift operator. The right shift operator >> shifts all of the bits in a
value to the right a specified number of times. Rightmost bit is lost when this shift occur.
leftmost position after ">>" depends on sign extension. If the number is negative, then 1 is used
as a filler and if the number is positive, then 0 is used as a filler.
For example:
int a = 35;
a = a >> 2; // a now contains 8
00000000 00000000 00000000 00100011 35 >> 2
00000000 00000000 00000000 00001000 8
int a = -8;
a = a >> 1; // a now contains -4
11111111 11111111 11111111 11111000 –8 >>1
11111111 11111111 11111111 11111100 –4
 The >>> is right shift unsigned operator. It shifts bits towards right. Zeros are fill in the left
bits regardless of sign.
For example:
int a = -1;
a = a >>> 24;
11111111 11111111 11111111 11111111 –1 in binary as an int
>>>24
00000000 00000000 00000000 11111111 255 in binary as an int

2.What is the difference between & and &&.:

 difference between & and &&


3.

Comments