I am Java beginer and I have to make a program that enters a String using command line and then prints the number of the entered words, the entered words and the sorted words. I can do everything except the sorting. I know I have to use compareTo, but I don't know how to make the method work. Would love to get some help!
Here's my code so far:
class Sort{
public static void main(String args[]){
int count=args.length;
System.out.println("\nYou've enetered "+count+" word and they are:");
for(int i=0;i<count;i++)
{System.out.print(args[i]+" ");}
System.out.println("\nThe sorted words are:");
}
}