Computer Science, asked by charu364431, 1 year ago

difference between compareto and equals​

Answers

Answered by candy93
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
candy93: Welcome
candy93: Dear
Answered by yuvika212005
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