I wrote a skeleton class that implements the Queue interface. When i compile, i get an ErrMsg asking to implement the add method from Object class(or does it refer to Object interface? I looked up both in the Java API and none of them even has an add method)
Why do i get this error and does it mean that a non-abstract class which implements a given interface needs to implement all the methods from the implemented class? I would have thought not.
import java.util.* ;
class ArrayQueue implements Queue
{
private Object[] elems ;
private int front, rear, length ;
public static void main(String[] args)
{
System.out.println("Hello World!");
}
public ArrayQueue(int maxLength)
{
length = 0 ;
front = 0 ;
rear = 0 ;
elems = new Object[maxLength] ;
}
public boolean offer(Object o) {}
public Object poll() {}
public Object remove() {}
public Object peek() {}
public Object element() {}
}
compiler message:
ArrayQueue is not abstract and does not override abstract method add(java.lang.Object) in java.util.Queue
btw, is there an other tag than homework to say that this is done in the context of studying? it's not homework i'm doing but its as close as it gets to what i do: study...
[EDIT]
i have been looking at this API page and it doesn't mention add()...am i looking at the wrong page?