Why we override equals() method?
Page 1 of 1
Why we override equals() method?
The equals method is used to check whether two objects are same or not. It needs to be overridden if we want to check the objects based on property.
For example, Employee is a class that has 3 data members: id, name and salary. But, we want to check the equality of employee object on the basis of salary. Then, we need to override the equals() method.
Similar topics
» Can subclass overriding method declare an exception if parent class method doesn't throw an exception ?
» What is a native method?
» What does join() method?
» What does the hashCode() method?
» What is the purpose of finalize() method?
» What is a native method?
» What does join() method?
» What does the hashCode() method?
» What is the purpose of finalize() method?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|