阅读背景:

这个字符串构造函数的实现如何工作(java)?

来源:互联网 
 public String(String original) {
     int size = original.count;
     char[] originalValue = original.value;
     char[] v;
     if (originalValue.length > size) {
         // The array representing the String is bigger than the new
         // String itself.  Perhaps this constructor is being called
         // in order to trim the baggage, so make a copy of the array.
         int off = original.offset;
         v = Arrays.copyOfRange(originalValue, off, off+size);
     } else {
         // The array representing the String is the same
         // size as the String, so no point in making a copy.
         v = originalValue;
     }
     this.offset = 0;
     this.count = size;
    this.value = v;
 }
 public String(String original) {
     int size



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: