我想在 main 方法中调用代码,但它似乎并没有真正起作用。
public class RecursiveSelectionSort {
public static void sort(double [] list){
sort(list, 0, list.length -1);
}
public static void sort(double [] list, int low, int high){
if (low < high){
int indexOfMin = low;
double min = list[low];
for(int i = low + 1; i <= high; i++){
if(list[i]< min){
min = list[i];
indexOfMin = i;
}
}
list[indexOfMin] = list[low];
list[low] = min;
sort(list, low + 1, high);
}
}
public static void main(String [] args){
double [] list = {3.0,4.0,1.0};//I tried but it doesn't work
System.out.print(sort(list));//it doesn't go to sort(list);
}
}
我想知道我是否可以调用它。这看起来很容易,但确实令人困惑。