Search Interview Questions
| More than 3000 questions in repository.|
There are more than 900 unanswered questions.
Click here and help us by providing the answer.
Have a video suggestion.
Click Correct / Improve and please let us know.
|Java - Interview Questions and Answers|
|Ans. equals, compareTo and hashcode are of use when the objects are used within collections. |
Equals helps with collections that helps maintaining only unique objects ( like Set )
compare and compareTo helps with collections that helps maintaining objects in order ( TreeSet, TreeMap etc )
hascode helps with collections that facilitates hash searching ( like hashSet, hashMap etc )
|Help us improve. Please let us know the company, where you were asked this question :|
|Like Discuss Correct / Improve  equals   compareTo   hashcode method|
|Can we override compareTo method for Enumerations ?|
|How TreeMap orders the elements if the Key is a String ?|
|If we add Enum constants to a sorted collection ( Treemap , TreeSet ), What will be the order in which they will be maintained ?|
|If compareTo() method returns zero, does it mean that the objects are always equal?|
|Difference between equals and compareTo in Java ?|