本帖最后由 杨锦 于 2012-8-5 19:24 编辑
private static void demo1() {
String s1 = "abc";
String s2 = "a" + "bc";
System.out.println(s1);
System.out.println(s2);
System.out.println(s1.equals(s2));
System.out.println(s1 == s2); // 为什么这个结果就是 true true
}
private static void demo2() {
String s1 = "abc";
String s2 = "a";
String s3 = "bc";
String s4 = s2 + s3;
System.out.println(s1);
System.out.println(s4);
System.out.println(s1.equals(s4));
System.out.println(s1 == s4);
} //而这个就是true flase
|