基于上文:http://www.jianshu.com/p/a20ee3bb9c1b

public String substring(int beginIndex, int endIndex) {
        int length = length();
        checkBoundsBeginEnd(beginIndex, endIndex, length);
        int subLen = endIndex - beginIndex;
        if (beginIndex == 0 && endIndex == length) {
            return this;
        }
        return isLatin1() ? StringLatin1.newString(value, beginIndex, subLen)
                          : StringUTF16.newString(value, beginIndex, subLen);
    }

substring(int beginIndex, int endIndex) 与 substring(int beginIndex)
不同在于 subLen 的赋值;
得出结论:subString(a,b)返回值是 str的索引位置a,到索引位置b(包括a,不包括b)

相关文章:

  • 2022-12-23
  • 2021-12-26
  • 2021-05-30
  • 2022-12-23
  • 2021-07-11
猜你喜欢
  • 2021-07-11
  • 2021-07-21
  • 2021-12-29
  • 2021-05-30
  • 2022-12-23
  • 2021-07-04
相关资源
相似解决方案