<分区>
我正在尝试在我的 int[]
上实现我的排序方法,该方法采用通用 E[]
作为参数。我收到错误:
The method sort(E[]) in the type HeapSort is not applicable for the arguments (int[]).
我的代码如下:
public <E extends Comparable<E>> void sort(E[] array){
//my code
}
public static void main(String[] args){
int[] arr = new int[30];
for(int rep = 0; rep < arr.length; rep++){
arr[rep] =(int )(Math.random() * 100 + 0);
}
System.out.println("The unsorted Array: ");
System.out.println(sort(arr).toString());
}
关于我为什么会收到此错误的任何想法?所有帮助表示赞赏!谢谢!