Please go through this following link. Hope this will help you.
CompareTo() method in Java must be compatible with equals method in Java i.e. if two objects are equal via equals method compareTo method must return “0″ for them, failing this may result in some subtle bug when you store those objects in collection class like arraylist in java. For detailed answer check here http://javarevisited.blogspot.in/2011/02/how-to-write-equals-method-in-java.html
Give proper explanation.
I am new in Java but I have knowledge about C programming.
Why do I need to override the equals and hashCode methods in Java? I mean Why always override hashcode() if overriding equals()?
Forgot Your Password?
2018 © Queryhome