Please help me to understand what is going on here:
Main.java:
int[] myarray = new int[125];
// setup the array here, code omitted.
int minimum = ProcessArray.min(myarray );
// the array values will now print as if they have been sorted...
for(int I=0; I<myarray.length;i++) {
System.out.Println(myarray[i]);
}
ProcessArray.java
import java.util.Arrays;
public class ProcessArray {
public static int min(int[] anarray){
Arrays.sort(anarray);
return anarray[0];
}
}
after finding the minimum value of the array, the array will print in sorted order.
Why does the array get re-arranged in sorted order?