I am having trouble getting the array to sort after the random numbers are generated in the array. I think the array is being sorted before all the numbers are assigned. I have tried nesting another for loop inside of the main one also, but I either get the same result or an endless loop of random numbers.
public static void main(String[] args) {
int[] anArray;
anArray = new int[10000];
Random generator= new Random();
for(int i=0; i<10000; i++){
anArray [i]= (generator.nextInt(98)+1);
java.util.Arrays.sort(anArray);
System.out.println(anArray[i];
}
}