为什么这段代码不起作用?你能给我一些帮助吗?
那么这段代码的问题是什么? 谢谢!!
import java.util.Scanner;
import java.io.*;
public class practice
{
public static void main (String[] args) throws IOException
{
final int DATA_NUM = 60;
String[] array = new String[DATA_NUM];
readData(array);
selectionSort(array);
printData(array);
}
public static String[] readData(String[] array) throws IOException
{
String filename = "input.txt";
Scanner file = new Scanner(new File(filename));
int count = 0;
while(file.hasNext())
{
String newLine = file.nextLine();
array[count] = newLine;
count++;
}
for(int i = 0; i < array.length; i++)
{
System.out.println(array[i]);
}
return array;
}
public static String[] selectionSort(String[] array)
{
for(int x = 1; x < array.length; x++)
{
int s = x - 1;
for(int y = x; y < array.length; y++)
{
if(array[y].compareTo(array[s]) < 0)
{
s = y;
}
}
String minValue = array[x-1];
array[x-1] = array[s];
array[s] = minValue;
}
return array;
}
public static String[] printData(String[] array)
{
for(int i = 0; i < array.length; i++)
{
System.out.println(array[i]);
}
return array;
}
}