我在Comparable接口的实现类Student中重写compareTo后compareTo的参数类型是Student,可是我在Demo中却能够在Comparable接口的实例化对象传递参数为Comparable类型的compareTo方法,为什么这样不会报错?
package fan;
public class Student implements Comparable<Student>{
public int compareTo(Student o){
return 0;
}
}
package fan;
public class Demo {
public static void main(String[] args) {
Student s1=new Student();
Comparable ss1=s1;
ss1.compareTo(ss1);
}
}