String与StringBuilder性能比对
程序员文章站
2022-04-10 14:05:47
//String与StringBuilder性能比对package seday01;/** * String修改字符串带来的性能开销 * @author xingsir * */public class StringDemo2 { public static void main(String[] a ......
//string与stringbuilder性能比对
package seday01;
/**
* string修改字符串带来的性能开销
* @author xingsir
*
*/
public class stringdemo2 {
public static void main(string[] args) {
string str = "a";
for(int i=0;i<10000000;i++) {
str = str+"a";
}
system.out.println("执行完毕!");
}
}
//=============================================================================
//package seday01;
///**
// * stringbuilder修改字符串的性能
// * @author xingsir
// *
// */
//public class stringdemo3 {
// public static void main(string[] args) {
// stringbuilder builder = new stringbuilder("a");
// for(int i=0;i<10000000;i++) {
// builder.append("a");
// }
// system.out.println("执行完毕!");
// }
//}
推荐阅读
-
C#中String和StringBuilder的简介与区别
-
java中String与StringBuilder的区别
-
string与stringbuilder两者的区别
-
浅析C#中StringBuilder类的高效及与String的对比
-
详解.NET中string与StringBuilder在字符串拼接功能上的比较
-
ASP.NET(C#) String, StringBuilder 与 StringWriter性能比较
-
Windows Phone开发之String与StringBuilder
-
秒懂String,StringBuilder与StringBuffer
-
18-09-20,String 与 StringBuilder (StringBuffer)
-
JAVA语法String字符串与StringBuilder使用详解