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.I took a look at the String class code, and the algorithm within compareTo and equals looks basically the same. I believe his opinion was just a matter of taste, and I agree with you -- if all you need to know is the equality of the Strings and not which one comes first lexicographically, then I would use equals
.