program to sort the string in alphabetical order in java

Simple java program to sort and  print the names in alphabetical order using compareTO(). To arrange the given strings in alphabetical order, first we need to compare each consecutive string and swap them according to the order. In this example, built-in function compareTo()  is used to compare two string.
Example of compareTo: