为什么s3==s4
返回false
而s2==s3
返回true
在行号。分别为8和7。字符串连接:带字符串文字的+运算符
1. String s="hello";`
2. String s1="he"+"llo";
3. String s2="hello"+123;
4. String s3="hello123";
5. String s4=ss+"123";
7. System.out.println(s==s1);//prints true
8. System.out.println(s2==s3);//prints true
9. System.out.println(s3==s4);//prints false
什么是'ss'?大概你的意思是'''? – Bathsheba
你在你的代码中有一个错字,你应该使用第5行中的一个s而不是两个ss: String s4 = s +“123”; 不是: String s4 = ss +“123”; – Abdelhak
java中的字符串比较应该使用字符串类的equals()方法完成。 – Patrick