ICSE Class 10 Computer Applications
Question 12 of 46
String Handling — Question 12
Back to all questions 12
Question Question 3(i)
Differentiate between equals() and compareTo().
| equals() | compareTo() |
|---|---|
| equals() checks if contents of two strings are same or not. | compareTo() compares two strings lexicographically. |
| The result is true if the contents are same otherwise it is false. | The result is a negative, positive or zero integer value depending on whether the String object precedes, follows or is equal to the String argument. |