/**
 * Simple insertion sort.
 * 
 * @param a
 *            an array of Comparable items.
 */
public static <AnyType extends Comparable<? super AnyType>> void insertionSort(AnyType[] a) {
int j; for (int p = 1; p < a.length; p++) {
AnyType tmp = a[p];
for (j = p; j > 0 && tmp.compareTo(a[j - 1]) < 0; j--)
a[j] = a[j - 1];
a[j] = tmp;
}
}
// function for  an randoming array
public static int[] RandomArray(int arrayLength, int maxNum) {
int[] array = new int[arrayLength];
for (int i = 0; i < array.length; i++) {
array[i] = (int) (Math.random() * maxNum);
}
return array;
}
public static void main(String[] args) {
int random = (int) Math.random() * 1000;
int[]randomArray = sort.RandomArray(random, 1000);
System.out.println("data amount" + random);
long begin1 = System.currentTimeMillis(); // 测试起始时间
sort.insertionSort(randomArray);// 测试方法
long end1 = System.currentTimeMillis(); // 测试结束时间
System.out.println("[insertionsort time]:" + (end1 - begin1)); // 打印使用时间在最后测试方法这一行,尝试把数组randomArray传入insertionSort这个函数时会报错The method insertionSort(AnyType[]) in the type sort is not applicable for the arguments (int[]),请问应该怎么解决呢?谢谢!