KnowledgeBoat Logo

Computer Applications

Differentiate between compareTo() and equals()

Java String Handling

ICSE 2006

42 Likes

Answer

compareTo()equals()
It compares two strings lexicographically.It checks if contents of two strings are same or not.
The result is a negative, positive or zero integer value depending on whether the String object precedes, follows or is equal to the String argumentThe result is true if the contents are same otherwise it is false.

Answered By

26 Likes


Related Questions