日期:2014-05-20 浏览次数:20679 次
String s1 = "a";
String s2 = s1+ "b";
String s3 = "a" + "b";
System.out.println(s2 == "ab");
System.out.println(s3 == "ab");
public class StringTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String s1 = "a";
String s2 = s1+ "b";
String s3 = "a" + "b";
System.out.println(s2 == "ab");
System.out.println(s3 == "ab");
}
}
public static void main(java.lang.String[]);
Code:
Stack=3, Locals=4, Args_size=1
0: ldc #16; //String a
2: astore_1
3: new #18; //class java/lang/StringBuilder
6: dup
7: aload_1
8: invokestatic #20; //Method java/lang/String.valueOf:(Ljava/lang/Objec
t;)Ljava/lang/String;
11: invokespecial #26; //Method java/lang/StringBuilder."<init>":(Ljava/la
ng/String;)V
14: ldc #29; //String b
16: invokevirtual #31; //Method java/lang/StringBuilder.append:(Ljava/lang
/String;)Ljava/lang/StringBuilder;
19: invokevirtual #35; //Method java/lang/StringBuilder.toString:()Ljava/l
ang/String;
22: astore_2
23: ldc #39; //String ab
25: astore_3