这是源程序:
String s = "";
for (int i = 0; i < 50000; i ++)
{
s += i;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 50000; i ++)
{
sb.append(i);
}
StringBuilder sb2 = new StringBuilder();
for (int i = 0; i < 50000; i ++)
{
sb2.append("s" + i);
}
String s3 = "";
for (int i = 0; i < 50000; i ++)
{
s3 = s3.concat(String.valueOf(i));
}
String s4 = "";
for (int i = 0; i < 50000; i ++)
{
s4 = s4.concat("s" + String.valueOf(i));
}
这是javac编译后的.class文件代码:
String s = "";
for(int i = 0; i < 50000; i++)
s = (new StringBuilder()).append(s).append(i).toString();
StringBuilder stringbuilder = new StringBuilder();
for(int j = 0; j < 50000; j++)
stringbuilder.append(j);
StringBuilder stringbuilder1 = new StringBuilder();
for(int k = 0; k < 50000; k++)
stringbuilder1.append((new StringBuilder()).append("s").append(k).toString());
String s1 = "";
for(int l = 0; l < 50000; l++)
s1 = s1.concat(String.valueOf(l));
String s2 = "";
for(int i1 = 0; i1 < 50000; i1++)
s2 = s2.concat((new StringBuilder()).append("s").append(String.valueOf(i1)).toString());
先留着,下班后过来总结下!