byte在Java中是8位签名.所以你会得到负值.
byte
更改
System.out.println(s[i]);
至
System.out.println(s[i]&0xff);
获得相同的价值观.
更新:我刚看到Java 8引入了Byte.toUnsignedInt().这可能更具可读性:
System.out.println(Byte.toUnsignedInt(s[i]));