我試圖編譯下面的程序,並不斷收到一個抽象方法錯誤。我試圖編譯的程序如下所示(但尚未完成)。我收到的錯誤是如下:Double不是抽象的,並且不重寫ListInterface中的抽象方法getNext()?
Double.java:5: error: Double is not abstract and does not override abstract method getNext() in ListInterface
public class Double<T extends Comparable<T>> implements ListInterface<T>{
^
where T is a type-variable:
T extends Comparable<T> declared in class Double
1 error
import java.io.*;
import ch06.lists.*;
import support.DLLNode;
public class Double<T extends Comparable<T>> implements ListInterface<T>{
protected DLLNode<T> front;
protected DLLNode<T> rear;
protected DLLNode<T> curPosition;
protected int numElements;
public Double(){
front = null;
rear = null;
curPosition = null;
numElements = 0;
}
protected DLLNode<T> find(T target){
}
public int size(){
return numElements;
}
public boolean contains(T element) throws NullPointerException{
if (DLLNode.getInfo()!=element){
return false;
}
else{
return true;
}
}
public boolean remove(T target) throws StackUnderflowException{
if (!contains(target)){
return false;
}
else{
return true;
DLLNode.setLink()==null;
}
}
public T get(T element){
return find(element);
}
public String toString(){
}
public void reset(){
}
@Override
public T getNext(){
return null;
}
public void resetBack(){
}
public T getPrevious(){
}
public void add(T element){
}
}
將@Override添加到所有您的重寫方法。它可以幫助你理解 – BobTheBuilder 2013-04-09 17:27:49
你可以使用ListInterface.java的代碼嗎? – 2013-04-09 17:28:26
@baraky使用找到「getNext」:) –
Vitaly
2013-04-09 17:31:19