+ 3
a == b, a is b
why the answers of "obj1 == obj2" & " obj1 is obj2" are different? (somtimes)
1 Odpowiedź
+ 5
Object has reference not values so comparison will be based on object reference.
The equality operator "==" will works well with primitive values not for reference values.
For object comparison u need to overload equals() and hasCode() methods in the class.
So in ur case obj1 and obj2 may have different references i.e. their hasCode values will be different.