I have below code
String s1=new String("hello");
String s2="hello";
System.out.println(s1.hashCode());
System.out.println(s2.hashCode());
System.out.println(s1==s2); //returns false
Why do we get last statement as false ,the hashcode of s1 and s2 is same can someone please explain?
and after i do String s3=s1.intern();
, System.out.println(s2==s3);
returns true
.