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.
    v = new char[size];
      System.arraycopy(originalValue, original.offset, v, 0, 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;
    }
标记出的if语句什么时候会得到执行,我怎么觉得它不可能执行呢!

解决方案 »

  1.   

    originalValue是一个字符数组,不是字符串.
    字符串的长度用length().
    数组的长度用length.
      

  2.   

    当参数original.length > 0 时执行
      

  3.   

    要搞清楚length()和length 
      

  4.   

    originalValue.length > size
    length是长度
    size是大小
      

  5.   

    public String(String original) { 
    int size = original.count; 其中count是什莫呢?求original的长度话,应该写成
    int size = original.length(); 
      

  6.   

    length是属性,一般用来说明数组的长度;length()是方面,是求数组中某个元素的字符串长度!
      

  7.   

    original.count 初始值为0只要初始化不是空的字符串就会执行的
      

  8.   

    这是String 的构造器,count   value 都是里面的属性
      

  9.   

    看看String源码,不就什么都明白了。
      

  10.   

    char 型的字符数组和String型的字符串 有啥区别
      

  11.   

    为什么会执行?
    new String("123");
    if (originalValue.length > size) 
    难道就会执行?
    size是0?
      

  12.   

    知道数组用length,String用length(),但源码看了半天没看懂!
      

  13.   

    http://topic.csdn.net/u/20081004/11/14f20243-ab87-4acb-ab32-1a638e6d3a07.html
    看这个帖子吧