我试图在我的 main 中调用 sort 方法,但我无法弄清楚如何正确地执行它。
public static void sortVehicles(Vehicle[] vehicles)
{
Arrays.sort(vehicles);
for(int i = 0; i < vehicles.length; i++)
{
System.out.println(vehicles[i]);
}
return;
}
我正在做这个......
public class
{
public static void main(String[] args) throws Exception {
Vehicle[] vehicles = fillArray(args[0]);
vehicles = fillArray(args[1]);
System.out.print("Enter 1 to print all of the files.\nEnter 2 to sort the files by email and print.\nEnter 3 to print the amount of files.\nEnter 4 to print only bike and truck files.\nEnter 5 to print only area codes (987).\nEnter number: ");
Scanner input = new Scanner(System.in);
int x = input.nextInt();
while (true) {
if (x == 1) {
printAll(vehicles);
} else if (x == 2) {
sortVehicles(vehicles);
} else if (x == 3) {
printRecordNumber(vehicles);
} else if (x == 4) {
printBicyclesAndTrucks(vehicles);
} else if (x == 5) {
printByAreaCode(vehicles);
}
}
}// end main
它给了我一个错误,说它无法识别 sortVehicle 的符号