difference between compareto and equals
Answers
Answered by
17
compareTo: Compares two strings lexicographically. equals: Compares this string to the specified object. compareTo compares two strings by their characters (at same index) and returns an integer (positive or negative) accordingly. ... Note that equals() doesn't define the ordering between objects, which compareTo() does.
charu364431:
thanks yarrr
Answered by
4
Answer:
The 2 main differences are that: equals will take any Object as a parameter, but compareTo will only take Strings. equals only tells you whether they're equal or not, but compareTo gives information on how the Strings compare lexicographically
*HOPE IT HELPS YOU*
Similar questions