Best Practise to Override Equals Method of Object Class

When we override equals method, always the argument of equals method should be Object type and inside the method then we should type cast it as per the requirement.

Eg: public boolean equals(Object obj) {
     Student std = (Student) obj;
 } ==> This is fine.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.