String s1 = \"Project\"; String s2 = \"Sunject\";
I want to compare the two above string by their alphabetic order (which in this case \"Project\"
As others suggested, you can use String.compareTo(String).
String.compareTo(String)
But if you are sorting a list of Strings and you need a Comparator, you don't have to implement it, you can use Comparator.naturalOrder() or Comparator.reverseOrder().
Comparator
Comparator.naturalOrder()
Comparator.reverseOrder()