I am writing the code shown below:
String s1=new String("hi");
System.out.println(s1.hashCode());
String s2=new String("hi");
System.out.println(s2.hashCode());
String s3=s1.intern();
String s4=s2.intern();
System.out.println(s3.hashCode());
System.out.println(s4.hashCode());
When I run the code the same hashcode is printing for all variables:
3329
3329
3329
3329
Is it correct output for the above code?
"iJ".hashCode()to confirm that different strings can also produce that same hash.