Here is the merge method of my merge sort algorithm
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] ;
But I keep on receiving a java.lang.Integer.compareTo(Unknown Source) error when this merge method is called. I am not sure how I am getting this error at the data[it2].compareTo(data[it3])
line because the while loop ensures both it2 and it3 dont go out of bounds.
Thanks