字符串连接方式性能比较

来源:互联网 发布:七天网络怎么绑定 编辑:程序博客网 时间:2024/05/02 00:43

1、通过+号连接

如String str1="abc";

    String str2="def";

    String str3="sidfji";

    String res ="";

    res+=str1;

    res+= str2;

    res+= str3;

2、StringBuffer

如 StringBuffer result = new StringBuffer();
        result.append(str1);
        result.append(str2);
        result.append(str3);
StringBuffer性能更好一些

0 0