我的任务是询问用户要输入的字符串数。然后我会提示他纠正这些错误。然后我要按字母顺序打印刺我完成了大部分的作业,只需要一个排序算法,比如bubble sort来完成它。这是我的密码。

import java.io.*;
public class sorting
{


private static BufferedReader stdin=new BufferedReader(new InputStreamReader( System.in));

  public static void main(String[] arguments) throws IOException
  {
     System.out.println("How many strings would you like to enter?");
     int stringCount = Integer.parseInt(stdin.readLine());
     String[] stringInput = new String[stringCount];
     for(int i = 0; i < stringCount; i++)
     {
         System.out.print("Could you enter the strings here: ");
         stringInput[i] = stdin.readLine();
     }
     //Now how do i use a sorting algorithm?
  }
}

最佳答案

Arrays.sort()

09-04 07:22
查看更多