日期:2014-05-20  浏览次数:20602 次

java String类的源码的疑问
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;
  }

这段是java的String类源码中的一个构造函数,应该怎么理解。那个original是怎么回事,还有那个count是在哪被始化的?

------解决方案--------------------
一起看看这个 JAVA String对象和字符串常量的关系解析 .
共同学习下~~~~ 原来堆 栈的问题有看了理解一些,久了不看又忘了哪个是哪个了