Java Alphabetizing Strings

后端 未结 7 1320
悲哀的现实
悲哀的现实 2021-01-19 04:27

I have a project for class were I need to get 4 different strings inputted and then output them in alphabetical order.

So far I have this:

String wd1         


        
7条回答
  •  感动是毒
    2021-01-19 04:42

    How about putting the Strings in a List and call the sort() method?

    The Java String class implements the 'Comparable' interface and thus already has the compareTo() method, which should compare the strings in order.

提交回复
热议问题