Hi,
Read the code,
public static void main(
String[] args) {
String siva=new String("sivakumar");
String siva2=new String("sivakumar");
String siva1="sivakumar";
String siva3="sivakumar";
System.out.println(siva.hashCode());
System.out.println(siva1.hashCode());
System.out.println(siva == siva1);
System.out.println(siva == siva2);
System.out.println(siva1 == siva3);
}
The output is:
1138315475
1138315475
false
false
true
My doubt is, == method check the hashcode and return true if two hashcode has the same value but the above code return false why?
Please answer my question clearly