String类和常量池
public class TestString {
public static void main(String[] args) {
String str1 = "abc";
String str2 = "a" +"b"+"c";
String str3 = new String("abc");
String str4 = str3 +"";
String str5 = new String("abc");
System.out.println("str1==Str2:"+(str1==str2));
System.out.println("str1==Str3:"+(str1==str3));
System.out.println("str1==Str4:"+(str1==str4));
System.out.println("str1==Str5:"+(str1==str5));
}
}
结果