String s1 = "abc";
String s2 = "abc";
System.out.println(s1 == s2);
System.out.println(s1.equals(s2));
String s3 = "a" + "b" + "c";
System.out.println(s3 == s2);
String s4 = "ab"; //面试题
String s5 = "abc";
String s6 = s4 + "c";//注意变量的返回值地址不同
System.out.println(s5 == s6);
System.out.println(s5.equals(s6)); |
|