e.g reference a------------> Object1
reference b------------> Object1
then a == b returns true.
- String class and Wrapper classes has override equals() method , so that two different objects could be compared to see if their contents are meaningfully equal.
- If classes equals() method is not overridden then it cannot be used as key in a Hashtable.
- equals() method in Object Class use only the == operator for comparison.
- If two objects are considered equal by using the equals() method then they should have identical hashcode values. So it is advisable to override hashCode() when equals() is overridden.
No comments:
Post a Comment