Byte有一个cache数组,存了-128--127
public static Byte valueOf(byte b)这个方法直接返回chache里的对象,这样可以提高效率,节省空间
private static class ByteCache { private ByteCache(){} 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)); } }