public class StringDemo { publicstatic void main(String[] args) { Strings2 = new String("abc"); Strings1 = "abc"; Strings3 = "ab"+"c"; System.out.println(s1.hashCode()); System.out.println(s2.hashCode()); System.out.println(s3.hashCode()); System.out.println(s1==s2); System.out.println(s1==s3); } } -------------- 运行结果: 96354 96354 96354 false true ------------ 疑问: s1==s2的结果为什么是false? |