好吧我承认标题是为了点击率
不扯淡真心求教
感谢赐教您的宝贵财富
①Byte.class 中类头:public final class Byte extends Number implements Comparable<Byte>
还发现一个类名为:Byte$ByteCache.class
棋类头为:public final class Byte extends Number implements Comparable<Byte> {
那么问题来了: 此类何来?
②Byte.class中:public static Byte valueOf(byte b) {
final int offset = 128;
return ByteCache.cache[(int)b + offset];
}
Byte$ByteCache.class中:
[code=Java]
static final Byte cache[] = new Byte[-(-128) + 127 + 1];
static {
for(int i = 0; i < cache.length; i++)
cache[i] = new Byte((byte)(i - 128));
}求解此二方法何意?
不扯淡真心求教
感谢赐教您的宝贵财富
①Byte.class 中类头:public final class Byte extends Number implements Comparable<Byte>
还发现一个类名为:Byte$ByteCache.class
棋类头为:public final class Byte extends Number implements Comparable<Byte> {
那么问题来了: 此类何来?
②Byte.class中:public static Byte valueOf(byte b) {
final int offset = 128;
return ByteCache.cache[(int)b + offset];
}
Byte$ByteCache.class中:
[code=Java]
static final Byte cache[] = new Byte[-(-128) + 127 + 1];
static {
for(int i = 0; i < cache.length; i++)
cache[i] = new Byte((byte)(i - 128));
}求解此二方法何意?
2.java的二进制采用的是补码形式
3.Java中的一个byte,其范围是-128~127的