我想讀取字符串並對它們進行排序。我收到了許多錯誤,這些錯誤在下面的代碼中出現。你能告訴我如何解決這些錯誤?Java字符串排序錯誤
package hw05;
/*
Demonstrates selectionSort on an array of strings.
*/
import java.util.Scanner;
public class Strings {
// --------------------------------------------
// Reads in an array of strings, sorts them,
// then prints them in sorted order.
// --------------------------------------------
public static void main(String[] args) {
String[] stringList;
String size;
Scanner scan = new Scanner(System.in);
System.out.print("\nHow many strings do you want to sort? ");
size = scan.nextLine();
**stringList = new String[size];**
System.out.println("\nEnter the strings...");
**for (String i = 0; i < size; i++)
stringList[i] = scan.nextLine();**
Sorting.selectionSort(stringList);
System.out.println("\nYour strings in sorted order...");
**for (String i = 0; i < size; i++)
System.out.print(stringList[i] + " ");**
System.out.println();
}
}
有什麼錯誤? –