This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
                            
                        
                    
                
                7年前关闭。
            
        

b将返回什么?

byte b = (byte)0x8A;
System.out.println("Value"+b);


它会打印什么?值何时返回否定值?

最佳答案

它会打印什么?


可能不是您所期望的。在Java中,byte是一个(有符号的)数字,而不是字符,因此,当0x8A转换为字符串时,您将获得一个小的负数的十进制表示形式。

所以我期望:

Value-118




如果您想将0x8A解释为字符,则应编写以下代码:

char c = (char) 0x8A;
System.out.println("Value" + c);


但这实际上也不起作用,因为Unicode代码点008A不是打印字符。 (就其价值而言,0x8A不是ASCII,因为真正的ASCII是7位字符集。)

08-16 12:45