在ECLIPSE中,写了一段这样的代码,不过却有一个错误出现,一直不太清楚是什么样的问题,谢谢达人们指教哈,顺便问一下怎么给分?呵呵
private static int indexOfSmallest(Comparable[] a, int first, int last)
{
Comparable min=a[first];
int indexOfMin=first;
for(int index=first+1;index<=last;index++)
{
*** if(a[index].compareTo(min)<0)
{
min=a[index];
indexOfMin=index;
}
}
return indexOfMin;
}
错误提示在***这一行,
提示信息是
Type safety: The method compareTo(Object) belongs to the raw type Comparable. 
 References to generic type Comparable<T> should be parameterized

解决方案 »

  1.   

    参数传的不对吧...min可能得到的不是CompareTo对象.
      

  2.   

    应该没错吧
    Comparable 是一个接口Type safety: The method compareTo(Object) belongs to the raw type Comparable. 
     References to generic type Comparable<T> should be parameterized
    这应该是一个警告,提醒参数(一般)应该是一个实现了Comparable的类。
      

  3.   

    Comparable min=a[first];这里应该将a[first] 附给一个实现了Comparable 接口的类的实列变量