Importance Of Overriding Equals And Hashcode Methods
In Java everything is an Object. Every class extends from class Object implicitly. The equals() and hashCode() are methods of Object class. These two methods works in conjunction with each other. The following sections explain why these methods needs to overridden and the effects of not overriding. Override equals() method The equals() method is used to compare two objects and returns a boolean value, which indicates whether the two compared objects are same in a meaningful way. We can also compare two objects using == (equality) operator, but this comparison results true only if both object references are referring to […]
Importance Of Overriding Equals And Hashcode Methods Read More »