public class ExampleString {
public static void main(String[] args) {
String s1="u cannot change me!";
String s2="u cannot change me!";
String s3="u cannot"+" change me!";
String s4="u cannot";
String s5=s4+" change me!";
final String s6="u cannot";
String s7=s6+" change me!";
System.out.println("s1==s2 "+(s1==s2));//true
System.out.println("s1==s3 "+(s1==s3));//true
System.out.println("s1==s5 "+(s1==s5));//false why it is false
System.out.println("s1==s7 "+(s1==s7));//true why it is true
System.out.println("s4==s6 "+(s4==s6));//true
// System.out.println("s5 "+s5);
// System.out.println("s7 "+s7);
System.out.println("s5==s7 "+(s5==s7));//false why
}
}
如果是s5进行连接,但它会给出输出错误 在s7的情况下也在进行连接,它会给出真实的。 我声明s6 am声明字符串作为最终字符串变得正确 我的问题是它为什么这样给予或者它们之间有什么区别