62,621
社区成员
发帖
与我相关
我的任务
分享
String st1 = "hello" + "world";
StringBuild sb = new StringBuilder("hello");
sb.append("world");
String st2 =Sb.toString();
public class Test {
public static void main(String args[]) {
String str1 = "hello" + "world";
String str2="helloworld";
System.out.println(str1==str2);
}
}public class Test {
public static void main(String args[]) {
String str1 = "hello" + "world";
String str2="helloworld";
System.out.println(str1==str2);
}
}import java.util.Date;
public class Test {
public static void main(String args[]) {
long t1=new Date().getTime();
for(int i=0;i<10000000;i++){
String st1 = "hello" + "world";
}
long t2=new Date().getTime();
for(int j=0;j<10000000;j++){
StringBuilder sb = new StringBuilder("hello");
sb.append("world");
String st2 = sb.toString();
}
long t3=new Date().getTime();
System.out.println(t2-t1);
System.out.println(t3-t2);
}
}