这是我的合并排序算法的合并方法
private void merge(T[] data, int first, int last) {
temp = new Comparable[data.length] ;
int mid = (first+last) /2 ;
int it1 = 0 ;
int it2 = first ;
int it3 = mid + 1 ;
System.out.println("mid = " + mid + " length = " + data.length);//for testing purposes
while(it2 <= mid && it3 < data.length)
{
System.out.println("it2 = " + it2 +" it3 = "+ it3);//for testing purposes
if(data[it2].compareTo(data[it3]) < 0)
temp[it1++] = data[it2++] ;
else
temp[it1++] = data[it3++] ;
}
while(it2 <= mid)
temp[it1++] = data[it2++] ;
while(it3 < data.length)
temp[it1++] = data[it3++];
for (int i = 0; i < data.length; i++)
data[i] = (T) temp[i] ;
但是在调用此合并方法时,我一直收到java.lang.Integer.compareTo(未知源)错误。我不确定我是如何在data[it2].compareTo(data[it3])
行收到此错误的,因为while循环确保it2和it3都不会超出范围。
由于