如题,
请研究过的前辈回答:同样是将byte[]转化为String,输出的结果为什么不是一样的,这其中哪个环节不一样?

解决方案 »

  1.   

    new 是在内存中申请的空间,对其装箱,是个对象。而前者只是个引用,在StringPool中。
      

  2.   

    第一个是调用Object类的toString()方法
    public String toString() {
    return getClass().getName() + "@" + Integer.toHexString(hashCode());
        }
    第二个是新建一个String 对象
    public String(char value[]) {
    int size = value.length;
    char[] v = new char[size];
    System.arraycopy(value, 0, v, 0, size);
    this.offset = 0;
    this.count = size;
    this.value = v;
        }
      

  3.   

    up up up up up up up up up