Discussion Forum Unit 4 Cs 2203
Discussion Forum Unit 4 Cs 2203
Checking the equality of objects among certain criteria makes it difficult to use the equals()
method. For example, if we are to compare sorted objects to know which comes first then we
need to override the equals() method since there is a natural notion of ascending order for
arbitrary objects (Eck, 2021).
The equals() method is commonly used by programmers and I think is good for comparing two
values of objects but when one needs to compare the locations of the objects in the memory
then the alternate is the "==". Also, when one needs to compare two objects based on criteria
such as which object comes first then the compareTo() method is a good alternative for that.
Reference