当前位置: 代码迷 >> J2SE >> java String类的源码的疑问解决方案
  详细解决方案

java String类的源码的疑问解决方案

热度:56   发布时间:2016-04-24 12:31:02.0
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对象和字符串常量的关系解析 .
共同学习下~~~~ 原来堆 栈的问题有看了理解一些,久了不看又忘了哪个是哪个了
  相关解决方案