基本上,我在想哪种方法是更好的实践方法,
for(int i = 0; i < 10000; i++){
System.out.print("blah");
}
System.out.println("");
或者
String over_9000_blahs = "";
for(int i = 0; i < 10000; i++){
over_9000_blahs += "blah";
}
System.out.println(over_9000_blahs);
还有没有更好的方法我不知道吗?
String
类型的+=
操作符会被转换为StringBuilder
。https://dev59.com/JnVD5IYBdhLWcg3wOo9h#47628 - jseashell