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++;
}
}
}
}
Without Arrays.sort(average) the program prints out all of the array values normally. However, if I add it in the values are all returned as zero. How do I fix this?
Arrays.sortdoesn't return any value.