本帖最后由 て淡莣了陌生 于 2013-4-28 10:29 编辑
class Demo1{
public static void main(String[] args) {
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);
}
}
class Demo2{
public static void main(String[] args) {
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,一个是false呢,不理解,求解释!!! |