나는 IVertex<T>
을 구현하는 클래스 Vertex<T>
을 가지고 있는데, 이는 Comparable
을 구현합니다. , 내 코드를 컴파일 할 때마다, 나는 오류가 발생합니다 :추상 클래스가 아닌 클래스는 Comparable에서 abstract 메서드 compareTo를 재정의 할 수 없습니까?
Vertex is not abstract and does not override abstract method compareTo(IVertex) in Comparable
이 가진 문제는 그 선생님이 지시 한 것입니다 나는 인터페이스 IVertex
내에서의 코드 중 하나를 변경할 수 있다는 것입니다. 이 문제를 어떻게 해결할 수 있습니까?
정점 : 나는 아래에있는 내 코드를 포함했다
package student_solution;
import graph_entities.*;
import java.util.*;
public class Vertex<T> implements IVertex<T>{
// Add an edge to this vertex.
public void addEdge(IEdge<T> edge){
}
// We get all the edges emanating from this vertex:
public Collection< IEdge<T> > getSuccessors(){
}
// See class Label for an an explanation:
public Label<T> getLabel(){
}
public void setLabel(Label<T> label){
}
}
IVertex :
package graph_entities;
import java.util.Collection;
public interface IVertex<T> extends Comparable<IVertex<T>>
{
// Add an edge to this vertex.
public void addEdge(IEdge<T> edge);
// We get all the edges emanating from this vertex:
public Collection< IEdge<T> > getSuccessors();
// See class Label for an an explanation:
public Label<T> getLabel();
public void setLabel(Label<T> label);
}
사전에 감사합니다!
글쎄, 당신이 (즉'공공 INT은 compareTo (IVertex을 구현하는 것을 잊었다 방법을 구현 V)'컴파일러는 클래스의 compareTo 메소드를 구현해야 함을 말하고있다 –
-.. 그게 다야 – duffymo
더 많은 오류 메시지를 읽고 (IVertex가 아니라'Vertex'라고 말합니다.) – EJP