我寫了一個代碼,應該採取一個數組,並將其從最小值到最大值排序,但我得到一個錯誤。這是代碼我的程序告訴我,我的方法對於我的類型沒有定義,這是什麼意思?
public class minHeapify{
public static void exchange(int a[],int i,int j) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
public static int parent(int i) {
return (int) Math.floor((i - 1)/2);
}
public static int left(int i) {
return 2*i + 1;
}
public static int right(int i) {
return 2*(i+1);
}
public minHeapify(int a[], int start,int end) {
int l = left(start); int r = right(start);
int smallest;
if(l >= end){
smallest = (a[l] < a[start])? l: start;
}
if(r >= end){
smallest = (a[r] < a[smallest])? r: smallest;
}
if(smallest != start) {
exchange(a,start,smallest);
minHeapify(a,smallest,end);
}
}
}
,我得到的是錯誤「的方法minHeapify(INT [],INT,INT)是未定義的類型minHeapify」和林不知道這意味着什麼。