import java.io.*;
import java.util.*;
import java.text.*;
public class aaa {
public static void main(String args[]) throws IOException {
Scanner sf = new Scanner(new File("C:\\temp_Name\\DataGym.in.txt"));
int maxIndx = -1;
String text[] = new String[1000];
while (sf.hasNext()) {
maxIndx++;
text[maxIndx] = sf.nextLine();
}
sf.close();
double average[] = new double[100];
for (int j = 0; j <= maxIndx; j++) {
Scanner sc = new Scanner(text[j]);
int k = 0;
while (sc.hasNext()) {
average[k] = Double.parseDouble(sc.next());
Arrays.sort(average); //returns 0
System.out.println(average[k]);
k++;
}
}
}
}
没有Arrays.sort(平均)程序会正常打印出所有数组值。但是,如果我在值中添加它们全部返回为零。我该如何解决?Java - Arrays.sort返回0
文件里面有什么? –
'Arrays.sort'不返回任何值。 – Andrew
和你期望什么? – Andrew