
The compareTo(T ob) method in the Comparable class is implemented in the String class and this implemented method takes java.lang.String as parameter. This method compares two strings lexicographically. The term lexicographically might seem new and weird. Whatever, don't get worried. I'll explain this method in a very easy way.