I recently gave an aptitude exam and encountered this piece of code:
public class MainClass{
public static void main(String[] argv){
int x = 0x80000000;
x = x >>> 31;
System.out.println(x);
}
}
At first I thought it must be some sort of error, but this gives a valid output of 1
. With x >> 31
, the output is -1
, which is understandable, but what does the extra >
do?