为什么移位运算符用在byte和short时得不到预想的结果???急
//:Shift.java
public class Shift{
public static void main(String[] args){
int i=-1;
System.out.println(Integer.toBinaryString(i));
i>>>=10;
System.out.println(Integer.toBinaryString(i));
long l=-1;
System.out.println(Integer.toBinaryString(l));
l>>>=10;
System.out.println(Integer.toBinaryString(l));
short s=-1;
System.out.println(Integer.toBinaryString(s));
s>>>=10;
System.out.println(Integer.toBinaryString(s));
byte b=-1;
System.out.println(Integer.toBinaryString(b));
b>>>=10;
System.out.println(Integer.toBinaryString(b));
b=-1;
System.out.println(Integer.toBinaryString(b));
System.out.println(Integer.toBinaryString(b>>>10));
}
}
/*output:
11111111111111111111111111111111
1111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111
11111111111111111111111111111111
11111111111111111111111111111111
11111111111111111111111111111111
11111111111111111111111111111111
1111111111111111111111
*/
在以上的例子中为什么short的s和byte的b操作后所产生的结果不是预期结果呢???