私のクラスヘッダー:
public class GraphEdge implements Comparable<GraphEdge>{
/** Node from which this edge starts*/
protected Point from;
/** Node to which this edge goes*/
protected Point to;
/** Label or cost for this edge*/
protected int cost;
私のcompareToメソッド:
@Override
public int compareTo(GraphEdge other){
return this.cost-other.cost;
}
しかし、Eclipseは私にエラーを与えます:
タイプ GraphEdge のメソッド compareTo(GraphEdge) は、スーパークラス メソッドをオーバーライドする必要があります
どうして?Comparable をやってみました
@Override
public int compareTo(Object o){
GraphEdge other = (GraphEdge) o;
return this.cost-other.cost;
}
しかし、これも失敗しました。