Hi Suhas,
equals() is better choice to test equalitity of Strin object. Also, its faster that compareTo().
compareTo() compares two strings lexicographically.The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence represented by the argument string.
equals() compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.
I hope this will help!
Thanks,
Samir