class Noname1
{
public static void main(String[] args)
{
byte i = (byte)-1;
System.out.println(Integer.toBinaryString(i));
}
}
运算结果为什么是32个1?
我明明已经将它强制转换成byte数据类型,为什么不是8个1呢?
------解决思路----------------------
Integer类的方法toBinaryString(int i)
你的实参已向上转型为int类型
------解决思路----------------------
Integer.toBinaryString()中参数类型为 int,他会byte自动转化为int类型