我希望我的类实现Comparable
接口。以下哪种方法是正确的
选项1:
public Myclass implements Comparable<MyClass>{
public int compareTo(MyClass o){
//impl here
}
}
选项 2:
public Myclass implements Comparable{
public int compareTo(Object o){
//check if o instance of my class
//impl here
}
}