Java中String的concat方法分析

2018-07-08  本文已影响42人  BestbpF

1、源码展示

    public String concat(String str) {
        int otherLen = str.length();
        if (otherLen == 0) {
            return this;
        }
        int len = value.length;
        char buf[] = Arrays.copyOf(value, len + otherLen);
        str.getChars(buf, len);
        return new String(buf, true);
    }

2、源码分析

上一篇下一篇

猜你喜欢

热点阅读