这2种定义方式 有不同吗??第一种会慢吗?
Your Answer
2 answers
第一种那不止是慢的问题,而是一段像屎的一样代码。
new StringBuilder("a").append("b").append("c");
new StringBuilder("a" + "b" + "c");
如果你像上面这种用,那还不如直接使用"a" + "b" + "c"因为没有使用到StringBuilder的任何特性,加上JDK的编译优化最终代码会变成如下。
new StringBuilder(new StringBuilder("a").append("b").append("c").toString());
第二种完全没看懂啊。使用StringBuilder的意义是什么?本身不就是一个字符串了吗?
Hot tools Tags
Hot Questions
Remove Primary Key in MySQL
2026-01-03 22:43:21
How to sort a HashMap in Java [duplicate]
2026-01-03 22:22:14
"selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element" while clicking a 'Next' button with Selenium
2026-01-03 22:01:28
Populate one dropdown based on selection in another
2026-01-03 21:44:04
Show / hide div on click with CSS
2026-01-03 21:22:12
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
Douyin level price list 1-75
20416
7
20416
7
wifi shows no ip assigned
13576
4
13576
4
Hot Article
How to set up price alerts so you don't miss key entry points?
2026-01-01
By DDD
Why do professional traders advise newbies to start with low leverage?
2026-01-01
By DDD
Tutorial on existence check of nested array values in PHP multidimensional array
2025-12-28
By DDD
How to draw dotted lines in PS How to draw various dotted lines in PS
2025-12-28
By DDD






